Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 208
DotnetSparrow Avatar asked Jun 09 '11 17:06

DotnetSparrow


People also ask

Can't Stop Services Access Denied?

The access denied error will be raised if the prompt does not have sufficient rights to stop the service. You see, Windows typically starts the command prompt (and other applications) without administrative rights — even if you are an administrator on your computer.


2 Answers

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.

like image 156
DrPppr242 Avatar answered Oct 02 '22 13:10

DrPppr242


You could do it in one line (useful for ci-environments):

taskkill /fi "Services eq SERVICE_NAME" /F 

Filter -> Services -> ServiceName equals SERVICE_NAMES -> Force

Source: https://technet.microsoft.com/en-us/library/bb491009.aspx

like image 26
totev Avatar answered Oct 02 '22 12:10

totev