Skip to content

How to Forcefully Terminate a Windows Service

Advertisement

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.

Unresponsive Windows Service
Unresponsive Windows Service

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.

  1. Find the Service name
  2. 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.

    Find Windows Service Name
    Find Windows Service Name

    In my case, the service name is AmazonSSMAgent.

  3. Find the PID
  4. 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.

    Check Windows Service PID
    Checking PID of Windows Service

  5. Kill Process by PID
  6. 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.

    Kill Windows Service by PID
    Kill Windows Service by PID

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.

Rahul

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

3 Comments

  1. 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

  2. Thanks, unfortunately even with the ‘force’ parameter, it seems sometimes Windows refuses… ‘access is denied’

Leave a Reply

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


Back to top