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.

Subscribe to VirtualizationHowto via Email 🔔

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Brandon Lee

Brandon Lee is the Senior Writer, Engineer and owner at Virtualizationhowto.com and has over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, Brandon has extensive experience in various IT segments and is a strong advocate for open source technologies. Brandon holds many industry certifications, loves the outdoors and spending time with family.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.