In Windows, sometimes a service may become unresponsive or stuck and cannot be stopped using the usual net stop or Task Manager methods. In such cases, you can force kill the service using the taskkill command. This tutorial will guide you through the process of force killing a service on Windows.
The Problem
In our AWS Windows server, the Amazon SSM Agent service was stuck during startup. The service status kept showing “starting” all the time.
The only option was to forcefully kill this service by the process ID on the Windows system. Below instructions will help you with it.
Step-by-Step Solution
Follow the below steps to find PID of service and forcefully terminate that.
- Find the Service name
Right-click on the service and open properties. Here you will find the service name under the General tab. For example, view the below screenshot.
In my case, the service name is AmazonSSMAgent.
- Find the PID
Then execute the below command with the service name identified above.
sc queryex [servicename]
This will show you the service details on the console as below.
- Kill Process by PID
Find out the service’s PID (process ID) and force kill the process by using the command below. Use the PID number found with the previous command.
taskkill /f /pid <PID>
Replace
with the actual Process ID of the service you want to force kill.
All done. You can now start your service again.
Conclusion
Using the taskkill command to force stop a service is a quick way to deal with unresponsive or stuck services on Windows. However, it should only be used as a last option because it can cause data loss or other problems if not done correctly. Always save your important data before you try to force stop a service, and only use this method if other ways to stop the service have not worked.
3 Comments
I once used task kill with the windows update service. Unfortunately, now I need to reopen it because a program needs window update security to open it after a long time. What should I do? Ty sir /madam
Thanks, unfortunately even with the ‘force’ parameter, it seems sometimes Windows refuses… ‘access is denied’
You need to run cmd as administrator