Kill a Windows service quick tip
Just a quick tip from the trenches that I have used numerous times over the years to deal with problematic Windows services. ย Let’s take a look at the “kill a Windows service quick tip”. ย You may have a service that is “hung” meaning it is starting or stopping without any results. ย Or I have seen on some occasions that you have a service that will not let you stop it for one reason or another.
Kill a service quick tip
Let’s step through the steps you can take to quickly kill a Windows service that isn’t behaving. ย The first thing that you need to do is to find the PID of the service. ย Every service spins up a different process ID that identifies this service from all the others. ย Of course many times, you can’t identify a service by simply looking at task manager as many will show up generically under theย svchost.exeย name which isn’t helpful to distinguish one service from another.
However, there is a command line tool that can help to identify the PID of the service in question. ย The first piece of information you need is the service name. ย Let’s look as an example at a common service – Windows Management Instrumentation. ย Below we see the service name isย Winmgmt which is what we will use to query.
Next, we run the command line utility that does all the heavy lifting for us:
sc queryex <service name>
It will give you the following similar output. ย Make note of theย PID which in this case is “800”.
Now we can see that theย svchost.exe entry is indeed running the Windows Management Instrumentation service. ย We can either kill it from here, or use the command line again.
To kill from the command line, we use theย taskkill command similar to the following:
taskkill /f /pid <PID>
So we would simply insert the PID for the service we queried for and it will kill the process and effectively kill the service.
Final Thoughts
Hopefully thisย Kill a Windows service quick tip will come in handy for anyone who has experienced a problematic service that would not stop or hung in starting.