简体   繁体   English

子进程被杀死时重新启动srvany

[英]Restart srvany when child process gets killed

I've created a service, which is a plain console application running via srvany.exe . 我已经创建了一个服务,它是一个通过srvany.exe运行的普通控制台应用程序。 It was set up to immediately restart when destroyed. 它被设置为在销毁时立即重启。 Here's the script: 这是脚本:

sc delete "Test Service"
sc create "Test Service" binpath= "C:\Windows\System32\srvany.exe" start= auto
sc failure "Test Service" reset= 86400 actions= restart/0
sc description "Test Service" Blah
reg add "HKLM\SYSTEM\CurrentControlSet\Services\Test Service\Parameters" /v Application /d "C:\<path>\testserv.exe"
sc start "Test Service"

It's created properly, and restarts if I kill srvany with taskmgr . 它已正确创建,如果我使用taskmgr杀死srvany ,则重新启动。 But when I kill testserv , srvany keeps running, effectively ruining my plans for immediate restart. 但是当我杀死testservsrvany继续运行,有效地破坏了我立即重启的计划。

Is there a (either console or registry) key for srvany to exit when its child process gets killed? srvany是否有(控制台或注册表)密钥在其子进程被杀死时退出? If not, is there any other simple ways to accomplish this task (without writing a service )? 如果没有,有没有其他简单的方法来完成这项任务(没有编写服务 )?

While srvany will gladly start your application as a service, it does not monitor the spawned process in any way to achieve what you want. 虽然srvany很乐意将您的应用程序作为服务启动,但它不会以任何方式监视生成的进程以实现您想要的目标。 We have a competing software called AlwaysUp; 我们有一个名为AlwaysUp的竞争软件; read more about srvany's shortcomings there. 阅读更多关于srvany在那里的缺点。

The article in CoreTech's answer is from AlwaysUp which itself is a paid application. CoreTech的答案中的文章来自AlwaysUp,它本身就是一个付费应用程序。 If you are looking for a free alternative that monitors child processes, try NSSM . 如果您正在寻找监控子进程的免费替代方案,请尝试NSSM

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

相关问题 当应用程序进程被杀死/崩溃时,杀死子进程 - Kill child process when application process is killed/crashed 如何在父进程被杀死/完成时保持子进程处于活动状态(在 Windows 中) - How to keep child process active when parent is killed/finished (in windows) 以QProcess :: startDetached开头的进程仍然是子进程,当父进程退出时被杀死 - Process started with QProcess::startDetached is still a child and killed when parent quits 如何保证在c ++中进程退出或被杀死时执行某些代码? - How to guarantee some code to be executed when the process exits or gets killed in c++? 强制终止进程时的进程退出代码 - Process Exit Code When Process is Killed Forcibly Perl:当子进程被杀死时,子子进程不会被杀死 - Perl: Child subprocesses are not being killed when child is being killed 使用SRVANY时无法读取注册表项 - Cannot read registry key when using SRVANY 杀死python进程时杀死子进程? - kill subprocess when python process is killed? 通过任务管理器杀死了Prunsrv exe,但子进程仍然存在 - Prunsrv exe killed via task manager but child process remains 检测到子进程因操作系统超出 memory 而被杀死 - Detecting that a child process was killed because the OS is out of memory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM