Windows

Kill a Windows service quick tip

A kill a windows service quick tip from the trenches. Using the command line and process ID we can get kill a service that isn't stopping.

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 a 7-time VMware vExpert, with over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, He 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. Also, he goes through the effort of testing and troubleshooting issues, so you don't have to.

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.