LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

terminating DOS window from system exec

Solved!
Go to solution

Hi, I'm using the system exec.vi to run a program, wait for the program to finish and then run it again with slightly different input parameters. This happens hundreds of times and works OK except sometimes the program crashes and the DOS window just sits there until you close it manually.

To stop this I want to detect how long the program runs for and if it's longer than 5 minutes or so, force it to close.

Detecting how long the program has run for isn't a problem, but I don't know how to force the window to close from labview....

 

can anyone help?

thanks,

Philip 

0 Kudos
Message 1 of 7
(4,633 Views)

 

I would look at killing the process for the System Exec, which you can do by using the Windows taskkill command.

ex: taskkill /yourexecutable.exe

 

The System Exec VI will run your executable in a separate process from LabVIEW.  LabVIEW by itself cannot kill the process, however, you can use a second System Exec to call a Windows command which will.  See the following link:
http://digital.ni.com/public.nsf/allkb/80432B061C5A4C888625705400737BE8?OpenDocument

0 Kudos
Message 2 of 7
(4,623 Views)

There are more examples here as well: http://search.ni.com/nisearch/app/main/p/bot/no/ap/global/lang/en/pg/1/q/kill%20windows%20process/


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
Message 3 of 7
(4,620 Views)

hmm that doesn't seem to work. It doesn't close the .exe so I used the example to try and close Windows Media Player.exe but it doesn't close that either 

 

the line is

taskkill /F /IM Windows Media Player.exe

 

is this correct?

0 Kudos
Message 4 of 7
(4,600 Views)

You need to use the correct task name - it's not always the same as the program name. Open up the Task Manager and look at the Processes tab. These have the image names. The correct image name for Windows Media Player is wmplayer.exe.

0 Kudos
Message 5 of 7
(4,595 Views)
Solution
Accepted by topic author pgo48

Try:

taskkill /f /im wmplayer.exe

 

 

0 Kudos
Message 6 of 7
(4,593 Views)

great, thanks to you both!

0 Kudos
Message 7 of 7
(4,587 Views)