During the test, you need to start and stop Windows service. Sometimes the service is in the stopping or starting status. However, in the services interface, the Start Service/Stop Service is gray and cannot be operated. Net start/stop servicename in the form of command line does not help. The method to stop the service is to disable the process, but it is often unable to determine which process is related to it. In the command line, we can use the SC queryex servicename command to obtain information about the service.
For example,
Run'SC queryex olsladtservice'In Command Prompt
The output is below,
SERVICE_NAME: olsladtservice
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: 4652
Flags:
Then we can use 'taskkill/PID 4652/F' in command prompt to kill the process./f means 'Kill forcely '.
The SC function is very powerful. For details, refer to the following two links:
Http://bartdesmet.net/blogs/bart/archive/2004/10/16/438.aspx
Http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ SC .mspx? MFR = true (more info on SC .exe)