How can I kill a specific process running in the background from the command line?

Assuming this is a Windows 7 machine, and we're talking about batch scripts on the Windows command line.

Imagine that I want to start and stop two different processes running in the background and start them while they are running in the background. For instance:

START /B CMD /C tomcatA.bat doSomeStuff stopTomcatACmd START /B CMD /C tomcatB.bat doSomeStuff stopTomcatBCmd 

I am trying to figure out how to implement stopTomcatBCmd . On a Linux machine, you can just kill pid .

My question is: How to kill a certain process running in the background on Windows?

+6
source share
3 answers

I think taskkill is what you are looking for. With it, you can kill a running process by its identifier or image name (.exe file name).

You can read a detailed explanation of use on this page: http://www.computerhope.com/taskkill.htm

+2
source

For such things, you can almost always find a utility that you can use as part of the Sysinternals package. In this case, I would recommend PsKill: https://technet.microsoft.com/en-us/sysinternals/pskill

Check out the article discussing the use of PsList and PsKill: http://windowsitpro.com/systems-management/pslist-and-pskill

0
source

TaskKill should do the job. you can write the exact name of the task to destroy, i.e. kill all firefox processes

 C:\>Taskkill /IM firefox.exe /F 

or you can check the PID of a specific task by writing a Tasklist, and then kill the task by specifying its PID ie

 C:\>Taskkill /PID 26356 /F 
0
source

Source: https://habr.com/ru/post/983307/


All Articles