LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

System Exec.vi Does Not Wait for BAT File to Finish in Windows 7 64bit

Highlighted

Hi,

 

I'm using System Exec.vi to execute a simple batch file which waits 3 seconds and exits:

"timeout /t 3 /nobreak"

I set the "Wait Until Completion" flag to TRUE but the VI returns immediately if I execute it on Windows 7 64bit. On Windows 10 64bit it works correctly. Do you know what could be the issue here?

VI was developed in LabVIEW 2015 SP1 32bit. Tested with LV18 with the same results.

VI Block Diagram.png

 *.bat extension is not allowed so I renamed the attached file extension to .txt.

CLA
Download All
0 Kudos
Message 1 of 9
(771 Views)
Highlighted

Try cmd /k 

 

CMD /C Run Command and then terminate

CMD /K Run Command and then return to the CMD prompt.

 

 BTW you do know that LabVIEW has a "Time Delay" function if all you need to do is wait 3 seconds.

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
Message 2 of 9
(735 Views)
Highlighted

@LucianM wrote:

Hi,

 

I'm using System Exec.vi to execute a simple batch file which waits 3 seconds and exits:

"timeout /t 3 /nobreak"

I set the "Wait Until Completion" flag to TRUE but the VI returns immediately if I execute it on Windows 7 64bit. On Windows 10 64bit it works correctly. Do you know what could be the issue here?

VI was developed in LabVIEW 2015 SP1 32bit. Tested with LV18 with the same results.

VI Block Diagram.png

 *.bat extension is not allowed so I renamed the attached file extension to .txt.


Wire something to your outputs.  You probably have some error that shows up in one of them, like the file wasn't found.  It works fine for me.  Whenever something doesn't work right with system exec, it's always useful to look at those outputs they give you.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 3 of 9
(732 Views)
Highlighted

I should have given more details: this batch file is not the actual file used in my app. This is just an example to simulate the execution of a batch file for 3 seconds. I need to wait until this batch file completes before I execute the rest of the code.

Standard error output is: "ERROR: Input redirection is not supported, exiting the process immediately."

Return Code = 1

VI Block Diagram2.png

Executing the batch file by double clicking on it in Windows Explorer, or by launching with Windows Run or with LabVIEW and System Exec.vi with Wait Until Completion set to FALSE, works as expected on both systems (Windows 7 and 10). If Wait Until Completion is TRUE, it does not work on Windows 7 64bit systems (tested on 4 already). Found out in the meantime that it also worked on a Windows 7 32bit computer.

@billko, I'm not sure I understood: the VI worked on your computer? If yes, what OS do you have? Did you execute the VI and saw the cmd window for 3 seconds and then VI finished execution?

 

CLA
0 Kudos
Message 4 of 9
(697 Views)
Highlighted

Wire the "Set working directory", that has tricked me on several occations.

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 9
(692 Views)
Highlighted

@LucianM wrote:

I should have given more details: this batch file is not the actual file used in my app. This is just an example to simulate the execution of a batch file for 3 seconds. I need to wait until this batch file completes before I execute the rest of the code.

Standard error output is: "ERROR: Input redirection is not supported, exiting the process immediately."

Return Code = 1

VI Block Diagram2.png

Executing the batch file by double clicking on it in Windows Explorer, or by launching with Windows Run or with LabVIEW and System Exec.vi with Wait Until Completion set to FALSE, works as expected on both systems (Windows 7 and 10). If Wait Until Completion is TRUE, it does not work on Windows 7 64bit systems (tested on 4 already). Found out in the meantime that it also worked on a Windows 7 32bit computer.

@billko, I'm not sure I understood: the VI worked on your computer? If yes, what OS do you have? Did you execute the VI and saw the cmd window for 3 seconds and then VI finished execution?

 


That is correct.  I wonder if it had something to do with me hardwiring the path?  (I cheated.  Instead of concatenating the path, I just cut n pasted the path along with the file name.)  The computer I ran this on was a Win10 machine.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 9
(684 Views)
Highlighted

I Googled the error and it seems to be related to that particular command.  (So riddle me this, Batman?  Why did it work on MY computer and not YOURS!  PCs are a weird species.)

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 9
(682 Views)
Highlighted

@Yamaeda wrote:

Wire the "Set working directory", that has tricked me on several occations.

/Y


I tried it already but the same:(

@billko, on Windows 10 is working also on my side. The problem appears only on Windows 7 64bit.

CLA
0 Kudos
Message 8 of 9
(665 Views)
Highlighted

@LucianM wrote:

@Yamaeda wrote:

Wire the "Set working directory", that has tricked me on several occations.

/Y


I tried it already but the same:(

@billko, on Windows 10 is working also on my side. The problem appears only on Windows 7 64bit.


Oops, I read your first post.  I'm an idiot.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 9
(642 Views)