简体   繁体   English

如何杀死卡在启动的Windows服务进程?

[英]How to kill Windows service process stuck at starting?

I have a problem with one service which stuck at starting stage when I try to start such service, and I am not able to terminate such process.当我尝试启动此类服务时,我遇到了一项服务的问题,该服务卡在启动阶段,并且我无法终止此类过程。 I know that restart is a solution, but server can't be restart couple times everyday, also any additional software like Process Explorer is not allowed to be installed and used.我知道重启是一种解决方案,但是服务器不能每天重启几次,也不允许安装和使用任何其他软件,如 Process Explorer。

So far I tried to use below solution (all commands were executed as admin):到目前为止,我尝试使用以下解决方案(所有命令均以管理员身份执行):

taskkill /f /pid 7788
ERROR: The process with PID 7788 could not be terminated.
Reason: Access is denied.

C:\Windows\system32>wmic
wmic:root\cli>process where name="ProcesName.exe" delete
Delete '\\xxxxx\ROOT\CIMV2:Win32_Process.Handle="7788"' (Y/N/?)? y
Deleting instance \\xxxxx\ROOT\CIMV2:Win32_Process.Handle="7788"
ERROR:
Description = Access denied
wmic:root\cli>


C:\Windows\system32>wmic
wmic:root\cli>process where name="ProcesName.exe" call terminate
Execute (\\xxxxx\ROOT\CIMV2:Win32_Process.Handle="7788")->terminate() (Y/N/?)? y
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 2;
};

wmic:root\cli>


C:\Windows\system32>taskkill /IM "ProcessName.exe" /T /F
ERROR: The process with PID 7788 (child process of PID 680) could not be terminated.
Reason: Access is denied.

C:\Windows\system32>tasklist | findstr 680
services.exe                   680 Services                   0      9 084 K
java.exe                      5832 Services                   0    443 680 K

1- Run PowerShell as an administrator 1- 以管理员身份运行 PowerShell

2- Enter: Get-Service like this pic After enter Get-Service command 2-输入: Get-Service like this pic输入Get-Service命令后

3- Enter: Stop-Service -Name "SERVICE-NAME" Like this Picture 3- 输入: Stop-Service -Name "SERVICE-NAME" Like this Picture

Example about stop service停止服务示例

the result after stop service停止服务后的结果

4- If service doesn't stop try this command 4-如果服务没有停止尝试这个命令

Set-Service -Name "SERVICE-NAME" -Status stopped -force

Another solution:另一种解决方案:

1- Open powershell or CMD as administrator. 1-以管理员身份打开powershell或CMD。

2- {{Path of service}} -k netsvcs 2- {{服务路径}} -k netsvcs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM