01-09-2012 07:08 AM
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
Solved! Go to Solution.
01-09-2012 07:42 AM
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
01-09-2012 07:51 AM
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/
01-10-2012 07:20 AM
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?
01-10-2012 07:48 AM
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.
01-10-2012 07:49 AM
Try:
taskkill /f /im wmplayer.exe
01-10-2012 07:51 AM
great, thanks to you both!