How to force kill a service on Windows

 Thank to: https://tecadmin.net/


In Windows, sometimes a service may become unresponsive or stuck and not 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.

Problem:

In our AWS windows server, the Amazon SSM Agent service was hung during the startup. The service status kept showing starting always.

Hanged Service on Windows

Now the only option available to forcefully kill this service by the process id on the Windows system. Below instructions will help you with it.

Solution:

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

    Find Windows Service name

    In my case the service name is AmazonSSMAgent

  • 2. 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.

    Find PID of Windows Service

  • 3. Kill Process by PID – Find out the service’s PID (process id) and force kill process by using the below command. Use 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 Process by PID on Windows

  • All done. You can now start your service now.

Comentarios

Entradas populares de este blog

Guía de herramientas básicas para estudiantes: 31 apps y webs imprescindibles para ayudarte con los estudios

Comando FOR para archivos BAT

How to Setup and Configure Your Own GitLab Server on Ubuntu 20.04