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 )?
source
share