How do I kill a specific process running in the background from the command prompt?

hawkeye picture hawkeye · Mar 4, 2015 · Viewed 14.4k times · Source

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

Imagine I want to start and stop two different processes running in the background, and run things whilst they running in the background. For example:

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

I'm trying to figure out how to implement the stopTomcatBCmd. On a Linux machine you could just kill the pid.

My question is: How do I kill a specific process running in the background in Windows?

Answer

Sledge Hammer picture Sledge Hammer · Mar 4, 2015

I think taskkill is what you're looking for. With it you can kill a running process by its ID or image name (name of the .exe file).

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