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

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.

Lucian
CLA
Download All
0 Kudos
Message 1 of 9
(3,431 Views)

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.

========================
=== Engineer Ambiguously ===
========================
Message 2 of 9
(3,395 Views)

@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
(3,392 Views)

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?

 

Lucian
CLA
0 Kudos
Message 4 of 9
(3,357 Views)

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

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 9
(3,352 Views)

@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
(3,344 Views)

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
(3,342 Views)

@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.

Lucian
CLA
0 Kudos
Message 8 of 9
(3,325 Views)

@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
(3,302 Views)