Skip to content

Instantly share code, notes, and snippets.

@mrzcn
Created December 13, 2020 10:21
Show Gist options
  • Save mrzcn/6d4723fbd48c2f52d5bc045ba7fb84f9 to your computer and use it in GitHub Desktop.
Save mrzcn/6d4723fbd48c2f52d5bc045ba7fb84f9 to your computer and use it in GitHub Desktop.
How to stop a service/program without restart wich lock/slown down system on a Windows machine
Sometimes as an administrator you may need to kill a service which is stuck at stopping in order to avoid having to reboot a server in the middle of the day.
Here’s what you need to do:
Step 1. 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”.
Step 2. Find out the PID of the service
Open an elevated command prompt and type in:
sc queryex servicename
(where servicename is the name of the service you obtained from Step 1.)
Make note of the PID
Step 3. Kill the PID
From the same command prompt type in:
taskkill /f /pid [PID]
Where [PID] is the service number.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment