Stopping Stuck Windows Services
When a Windows services fails to stop, it can get locked into the state where the service cannot be stopped or started.
Generally a reboot would fix this however the issue can return once the service needs to be stopped again.
If you wish to stop and/or remove the service, without bringing the host down, you can use some quick batch commands in order to regain control.
Identify the Service
First, start by opening services.msc
and finding the service that is stuck. Right click it and click Properties
. The service name will be highlighted, copy this to your clickboard to make the commands easier.
In this example we will be repairing the LogMeIn calling card. We have used this in the past to enable clients to quickly requets assistance however some Windows 10 machines triggers a bug where the service was stuck with status 'stopping'.
Stopping the Locked Service
Begin by opening an elevated command prompt.
Use sc
with the queryex
command to identify the service's PID
C:\WINDOWS\system32>sc queryex "LMIRescue_541aed02-17a9-2855-767r-9ba30aed04e1"
SERVICE_NAME: LMIRescue_541aed02-17a9-2855-767r-9ba30aed04e1
TYPE : 10 WIN32_OWN_PROCESS
STATE : 3 STOP_PENDING
(STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x7d0
PID : 3000
FLAGS :
Here we have a PID
of 3000
.
Using the PID
, forcefully kill the service.
C:\WINDOWS\system32>taskkill /PID 3000 /F
SUCCESS: The process with PID 3000 has been terminated.
Once the service process has been terminated, we can optionally remove the offending service using sc
.
C:\WINDOWS\system32>sc delete LMIRescue_541aed02-17a9-2855-767r-9ba30aed04e1
[SC] DeleteServices SUCCESS
Finally, with everything closed down, any locked files on the Windows file system can now be removed through normal means.