06-20-2008 05:30 AM
06-20-2008 05:59 AM
You can kill a process using the Windows taskkill command.
Thoric wrote:
Anybody know of a way to kill a running process called by System Exec?
06-20-2008 07:30 AM
06-20-2008 07:39 AM
06-20-2008 07:49 AM - edited 06-20-2008 07:50 AM
06-20-2008 09:00 AM
Thoric wrote:
Thanks for this. Presumably I could simple call:
taskkill /im plink.exe
to kill any running plink processes.
But what I'd really like is a method to return a process ID from System Exec to the exact running session of plink so that I know I'm killing the right process. There may be other running sessions of plink that my application ought to leave alone, so simply killing them all could be a bad idea.
06-20-2008 09:24 AM
06-20-2008 09:51 AM - edited 06-20-2008 09:52 AM
06-20-2008 09:57 AM
08-23-2016 07:42 AM
Thanks for sharing your solution Thoric! I have recently come across the need to do something similar myself.
I was considering something slightly different. Just before starting the plink.exe process, readout the output from 'tasklist' using System Exec, and then check if there are any active plink.exe processes running and note the PIDs for them. Then right after starting the plink.exe process check the output from 'tasklist' again using System Exec for any new PIDs for plink.exe. Based on the speed of the operation you should usually be able to determine the PID of the process you started. And then later use that to kill it. Just a slightly different workaround to the problem.