Windows – How to Kill hung service – Windows Service Which is Stuck

Sometimes as an administrator you may need to kill a service which is stuck in a ‘starting’ or ‘stopping’ state, in order to avoid having to reboot a server in the middle of the day.

These are the simple steps you need to do:

Find out the Service Name:

To do this, go in to services and double click on the service which has stuck.  Make a note of the “Service Name”.

Find out the PID of the service

To kill the service you have to know its PID or Process ID.

Open an elevated command prompt and type in:

sc queryex servicename

(where servicename is the name of the service you obtained from Step 1.)

Replace ‘servicename’ with the services registry name. For example: Print Spooler is spooler. (See Picture)

After running the query you will by presented with a list of details. You will want to locate the PID. (Highlighted)

Kill the PID

Now that you have the PID, you can run the following command to kill the hung process.

From the same command prompt type in:

taskkill /f /pid [PID]

Where [PID] is the service number.

This will force kill the hung service. (See Picture)

If it is successful you should receive the following message:

SUCCESS: The process with PID XXXX has been terminated.

Be careful of what you are killing though.  If you kill a critical windows service you may end up forcing the machine to reboot on it own.

Note: By forcing a service to stop you can also use these instructions to Kill a Windows Service which is stuck at starting as well.  This will allow you to restart the service.

Ref: SpiceWorks  Support4IT

Related Posts

Exit mobile version