Restarting a Stuck Service

From time to time, you might find yourself in a position where you need to restart a service that's stuck in a "starting" or "stopping" state. While this is happening, you won't be able to interact with the service via the Services Management Console (services.msc).

Before you can kill the stuck process, you have to have know what the ID is. To do this, run sc queryex from the command prompt. Doing this can return a lot of results, so I like to pipe them into a text file for easy viewing/searching:
 

sc queryex > processes.txt  




Once completed, open it in a text editor to find your process:
 

notepad processes.txt  



Looking at the file, you'll see a list of your services and what state their in. You should be able to locate the stuck service by name:

SERVICE_NAME: AppNameDISPLAY_NAME: Some Application Service Service        TYPE               : 20  WIN32_SHARE_PROCESS           STATE              : 4  RUNNING                                   
 (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)         WIN32_EXIT_CODE    : 0  (0x0)         SERVICE_EXIT_CODE  : 0  (0x0)         CHECKPOINT         : 0x0         WAIT_HINT          : 0x0         PID                : 1527         FLAGS              :   

The specific fields to pay attention to are DISPLAY_NAME (friendly name of the service), STATE (running, stopped, starting, stopping etc.), and PID (Process ID).

The PID is especially important because we need it to determine what process to kill. In the example above, the PID is 1527, we'll use this number in the next command,TASKKILL:

taskkill /PID 1527 /F

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值