Despite being almost 20 years old, Microsoft’s free Srvany utility is still a surprisingly popular tool. Every week, we come across at least one person using the ancient service wrapper to install an executable or batch file to start at boot as a Windows Service.
Truthfully, Srvany is fine for many situations. It’s basic, and it works. And the price is right.
However, the utility has several shortcomings that aren’t immediately obvious. Here are the top 3 that we (and our customers) have encountered over the years:
Problem #1: Srvany may continue to run even though your application is dead
When it is started, a Srvany service immediately launches its target application. And if the application starts properly and runs without interruption, everything is great.
But what happens if the application crashes or stops running?
To find out, we created a new service that runs the Windows Notepad text editor:
When we started the service, Srvany launched notepad.exe as instructed. Here you can see the service in the “Running” state with Notepad operating in Session 0:
Next, we forcibly terminated Notepad.exe. As expected, the process disappeared.
However, even after Notepad had exited, the service remained in the “Running” state. Misleading, to say the least.
Basically, you cannot rely on the state of a Srvany service to reflect the state of the target application. Just because the service says its running doesn’t mean that the application is!
Problem #2: Srvany may leave your application running after the service stops
As described in this article, when you stop a Srvany service, only the target application is closed. If the target application had launched other applications, those others will not be stopped.
This can be a problem for batch files and applications involving multiple processes.
To illustrate, we installed a new Srvany service that runs a batch file. The batch file starts Notepad:
When we started the service, Srvany launched the batch file, which started Notepad. So far so good:
However, when we stopped the service, only the batch file (cmd.exe) was terminated. Notepad continued to run, alive and well — despite the service being in the stopped state.
Here again, the state of the service does not reflect the state of the target application. But there are unwelcome side effects too.
If we start the service again, Srvany will launch a fresh copy of Notepad. And then we have two copies of Notepad running. This “duplicate” scenario can create chaos for more complex situations, for example with applications that should not run multiple instances. Watch out!
Problem #3: Srvany isn’t particularly user friendly
According to our customers, Srvany comes up short in three areas of usability:
There is no GUI to install your application as a service. You must use a separate command line tool (Instsrv) to create a new Srvany service, which is less than ideal.
To configure the application to run, you have to create keys and values with the Windows Registry Editor — an administrative tool that can cripple your PC if you use it incorrectly.
Srvany is difficult to troubleshoot because it doesn’t write a log file or provide helpful feedback when things go wrong. As a result, frustration often ensues.
Proceed with caution!