LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control+C Command to Execution Sytem

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.

Rolf Kalbermatter
My Blog
Message 11 of 15
(498 Views)

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

0 Kudos
Message 12 of 15
(487 Views)

Hello GowthamRajegowda,

Try sending "taskkill /IM cmd.exe"   instead of "ctrl-c" it will close the command prompt.


CLD Using LabVIEW since 2013
Message 13 of 15
(483 Views)

Hi Gowtham,

 

please don't create double threads on the same topic!

(I merged your two threads.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 14 of 15
(475 Views)

thank you Sir

0 Kudos
Message 15 of 15
(468 Views)