Windows srvany.exe and the STOP service

I read a lot of answers on the Internet about how to use SRVANY.exe to create a Windows service from anything. My service is a batch file that sets up the environment (I need to install env vars and disk maps) and then spawns my C ++ application. But when I do NET STOP, the srvany.exe process disappears and my C ++ application stays alive. Is there any way to kill him when he receives a stop command? I will need to bounce from it in case of any changes to the configuration file.

The reason I chose shell is because of the simple display of the disk. In theory, I can wrap it in either perl or python, depending on which is easier to get this behavior, but then I will need to lay out a shell anyway to map the disks. It makes sense?

+3
source share
2 answers

AlwaysUp is a commercial alternative to SrvAny, which covers such disadvantages as adding more useful features.

NSSM is an open source alternative with slightly fewer features than AlwaysUp, but it can kill the underlying process when the service stops.

+3
source

no, srvany was not meant to stop your applications. The main goal was to run applications as services that were not designed to function as a service. As a clumsy workaround, you can run a scheduled task that will keep track of whether srvany will start, and if that doesn't stop your application.

+2

Source: https://habr.com/ru/post/1717693/


All Articles