Restart srvany on child process destruction

I created a service, which is a simple console application launched through srvany.exe. It was configured to restart immediately upon destruction. 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 is created correctly and restarts if I killed srvanywith taskmgr. But when I kill testserv, it srvanycontinues to work, which actually destroys my plans for an immediate restart.

Is there a key (or console or registry) srvanyto exit when its child process is killed? If not, are there other simple ways to accomplish this task (without a service record )?

+4
source share
2 answers

While srvany will happily launch your application as a service, it will not track the generated process in any way to achieve what you want. Read more about srvany flaws here .

+2
source

CoreTech's answer contains an AlwaysUp article, which itself is a paid application. If you are looking for a free alternative that controls child processes, try NSSM .

+2
source

All Articles