Maintenance on Windows Devices sometimes requires the manual stopping/restarting of Services. Sometimes these services play nice, and sometimes they do not. Aside from restarting the system, there are some built-in commands that will allow you to stop and/or restart individual services.
First, locate the service that you are attempting to fix, and remember it’s Display Name (the name listed in the Service Management Snap-in, see above for an example). Once you have the display name, open a Command Prompt Window (run as Administrator) and enter the following command:
You should see an output similar to the following. Take note the Process ID (PID) in this output (shown below in bold)
Copyright (c) 2009 Microsoft Corporation. All rights reserved.C:\Users\Administrator>sc queryex “Windows Agent Service”
SERVICE_NAME: Windows Agent Service
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 STOPPING
(STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
PID : 4584
Now that you have the PID for the hung service, you can enter the following command to force it to terminate:
You can re-enter the “sc queryex” command to verify it is stopped, or refresh your view in the Services Management Snap-in in order to verify the service has actually stopped. To restart the service, you can enter the following command, or start the service from the Snap-in.