Pregunta

I've created a service, which is a plain console application running via 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. But when I kill testserv, srvany keeps running, effectively ruining my plans for immediate restart.

Is there a (either console or registry) key for srvany to exit when its child process gets killed? If not, is there any other simple ways to accomplish this task (without writing a service)?

¿Fue útil?

Solución

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. We have a competing software called AlwaysUp; read more about srvany's shortcomings there.

Otros consejos

The article in CoreTech's answer is from AlwaysUp which itself is a paid application. If you are looking for a free alternative that monitors child processes, try NSSM.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top