03-03-2015 04:42 PM
I have two CMD windows open runnig a LabVew launched commandline program
It is two instances of the iperf program and I found this searching here
taskkill /F /IM iperf.exe
That works but it kill both windows.
I take it I need to find the PID on the two windows and only kill the one I want
How do I find the PID?
Is there a better way?
03-03-2015 05:23 PM
03-03-2015 09:40 PM
Thanks, you wouldn't happen to have a better keyword search?
Because using PID brings of thousands of hits for PID controllers and the associated PID toolkit.
03-03-2015 11:57 PM
03-04-2015 12:20 AM
Try .NET instead of command line.
Works for Windows application.
Might work for CMD window too.
03-04-2015 01:08 AM - edited 03-04-2015 01:33 AM
You can change the title of the command line windows with the TITLE command, i.e. TITLE mycmd_task1 or TITLE mycmd_123.
Now taskkill /FI "windowtitle eq mycmd_task1" will kill the first window, etc...
I tried this without LabVIEW, just 2 command line windows named 'win1' and 'win2'. It works. Only one of the instances cancels execution. Since the name of the program adds also to the title it is easier to use wildcard in the filter. When you run 'iperf ' the window title will be 'win1 - iperf -c ..........', so you can use taskkill /FI "windowtitle eq win1*" respectively taskkill /FI "windowtitle eq win2*"
03-04-2015 01:19 AM
03-04-2015 09:55 AM
@chembo wrote:
You can change the title of the command line windows with the TITLE command, i.e. TITLE mycmd_task1 or TITLE mycmd_123.
Now taskkill /FI "windowtitle eq mycmd_task1" will kill the first window, etc...
I tried this without LabVIEW, just 2 command line windows named 'win1' and 'win2'. It works. Only one of the instances cancels execution. Since the name of the program adds also to the title it is easier to use wildcard in the filter. When you run 'iperf ' the window title will be 'win1 - iperf -c ..........', so you can use taskkill /FI "windowtitle eq win1*" respectively taskkill /FI "windowtitle eq win2*"
That does not seem to work.
The title has C:\Windows\system32\cmd.exe - C:\iperf\iperf -s -u -p50002 -i2 -l300M
Taskkill /F /IM "C:\Windows\system32\cmd.exe - C:\iperf\iperf -s -u -p50002 -i2 -l300M"
ERROR: Invalid query
As does Taskkill /F /IM "cmd.exe - C:\iperf\iperf -s -u -p50002 -i2 -l300M"
and Taskkill /F /IM "C:\iperf\iperf -s -u -p50002 -i2 -l300M"
03-04-2015 10:00 AM - edited 03-04-2015 10:01 AM
@RTSLVU wrote:
@chembo wrote:
You can change the title of the command line windows with the TITLE command, i.e. TITLE mycmd_task1 or TITLE mycmd_123.
Now taskkill /FI "windowtitle eq mycmd_task1" will kill the first window, etc...
I tried this without LabVIEW, just 2 command line windows named 'win1' and 'win2'. It works. Only one of the instances cancels execution. Since the name of the program adds also to the title it is easier to use wildcard in the filter. When you run 'iperf ' the window title will be 'win1 - iperf -c ..........', so you can use taskkill /FI "windowtitle eq win1*" respectively taskkill /FI "windowtitle eq win2*"
That does not seem to work.
The title has C:\Windows\system32\cmd.exe - C:\iperf\iperf -s -u -p50002 -i2 -l300M
Taskkill /F /IM "C:\Windows\system32\cmd.exe - C:\iperf\iperf -s -u -p50002 -i2 -l300M"
ERROR: Invalid query
As does Taskkill /F /IM "cmd.exe - C:\iperf\iperf -s -u -p50002 -i2 -l300M"
and Taskkill /F /IM "C:\iperf\iperf -s -u -p50002 -i2 -l300M"
Oh... I see you were using the FI argument
Taskkill /FI "C:\Windows\system32\cmd.exe - C:\iperf\iperf -s -u -p50002 -i2 -l300M" and every other variation yelds:
ERROR: The search filter cannot be recognized
03-04-2015 10:06 AM - edited 03-04-2015 10:08 AM
You need to use the /FI "windowtitle ..... filter option in the taskkill command in order to find the window. I don't see this in your example.
And also use the TITLE command first in order to rename each CMD window, so that you can stop just one of them. Since you need two commands,
I would put them in a batch file:
title win1
C:\iperf\iperf -s -u -p50002 -i2 -l300M
Your CMD window should have then title similar to win1 - C:\iperf\iperf -s -u -p50002 -i2 -l300M
and you can kill it with taskkill /FI "windowtitle eq win1*"
Then you name the second window win2, etc...