Killing the process of a Service in a Windows system

If you have a service that does not respond, for example, a hanged service stuck in starting or stopping, you might need to kill the process manually.
In this post, we are going to kill one service process, to be able to force a service to stop.
We will need the PID of the process, so here is where we start.

Finding out the PID of the service process

To do this, we will need the service name. We will see two different ways of getting that name.
You can see the name of the process in the “services.msc” console, or you can manually find it in the command line.

 Using the Service console

Open the service console the way you usually do, for example “services.msc“, and look for the service you want to kill.
Right click and select Properties, in General tab, you can find the Service Name.

In the example, the service is “wuauserv“.
Let’s open a command prompt as administrator, and use “sc queryex <servicename>” to query the details about this service.

sc queryex wuauserv


Here you have the PID of the process. In our example, the PID is 1220.
Now just use “taskkill” to eliminate it.

taskkill /f /pid 1220

And there it is, process/service stopped.

From command line

If we have some problem that does not allow us to look into the services console, we can look for the service name manually in the command prompt.
Use “sc queryex” to see the whole list of services.

sc queryex >full_list.txt
type lista_completa.txt|more

In the example, we create full_list.txt with all services, then explore it with type, notepad or any other way.
From that output, you have the name of the process and the PID, so once you have it, use “taskkill” to stop it.

taskkill /f /pid 1220

If you want to kill any process in the system, not only the service ones, check our “Killing a process from Windows command line” post.

Leave a Reply

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