1. Home
  2. System Administration
  3. Troubleshooting
  4. Windows – Kill a Service via the Command Prompt (CMD)

Windows – Kill a Service via the Command Prompt (CMD)

Sometimes you will find yourself in a situation where a Windows service is stuck and cannot be stopped through Task Manager or the Windows Services application. Be careful which services you are stopping. If you stop an important Windows service the server could reboot. Follow the steps below to kill the service.

  1. Identify the Service Name. In the Services application locate your service, right click and select Properties. You will need the service name and not the display name.
This image has an empty alt attribute; its file name is image.png
Properties of the MySQL Server. In this instance the service name is the same as the display name.

2. Identify the Process Identifier Number (PID) of the service. Open the command prompt with administrator privileges and type the command shown below. Replace servicename with the name of the service from step.

This image has an empty alt attribute; its file name is image-2.png
sc queryex servicename 

Make note of the PID. In the screenshot below it is 5952.

This image has an empty alt attribute; its file name is image-1.png

3. Use taskkill to stop the PID. From the same CMD type in the command shown below. Replace PID with the PID number from step 2. If it is successful it should return SUCCESS: The process with PID #### has been terminated

taskkill /f /pid PID
This image has an empty alt attribute; its file name is image-2.png
Updated on August 10, 2019

Was this article helpful?

Related Articles