06-25-2019 04:04 AM
Control-C is a keystroke send to the current application and the convention for command line programs is to terminate on that. There is no simple way to terminate a program you started through the SystemExec call.
SystemExec starts a process and once it returns, that process is running independently from the LabVIEW process until it terminates (unless you wire a true constant to the "wait until completion" in which case SystemExec only returns after the process has terminated itself somehow).
Trying to call a second SystemExec with some magic commands does absolutely nothing for the first process started. In the best case it starts a second process if the command line specifies a valid program, but in your case it simply returns an error since it can't start a process with the name "ctrl-c".
There are a few possible approaches but non of them is a simple one:
1) You could try to enumerate all the processes in memory and find the process you started and send it the ctrl-c keystroke as a Windows message. This is going to be a major effort to develop.
2) issue a "
taskkill /IM "process name"
through a second SystemExec. Beware this does what the name says, it kills the process instantly, without letting it save anything or whatsoever. Kill means shoot it and instant dead.
3) implement in your Python program some routine that waits for instance on a TCP port for commands and then send it from LabVIEW with the TCP nodes the command to quit.
06-25-2019 04:10 AM
Hello Sir,
Thank You for your response and suggestion
I have doubt you said that use taskkill /IM "process name" command which will kill the process does this effect the vi or running exe other than not letting to save it
06-25-2019 05:41 AM
Hello GowthamRajegowda,
Try sending "taskkill /IM cmd.exe" instead of "ctrl-c" it will close the command prompt.
06-25-2019 06:31 AM
06-25-2019 06:37 AM
thank you Sir