Search code examples
windows-services

Stopping a windows service when the stop option is grayed out


I have created a windows service and in the service in control panel -> administrative tools -> services, its status is starting.

I want to stop this service, but the stop option is grayed out. How can I start/stop the service?

Every time I restart, then it becomes stopped and I can delete it.


Solution

  • If you run the command:

    sc queryex <service name>
    

    where is the the name of the service, not the display name (spooler, not Print Spooler), at the cmd prompt it will return the PID of the process the service is running as. Take that PID and run

    taskkill /F /PID <Service PID>
    

    to force the PID to stop. Sometimes if the process hangs while stopping the GUI won't let you do anything with the service.