Windows

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.

servicekill01

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.

servicekill02

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”.

servicekill03

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.

servicekill04

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.

Back to top button