The Core Technologies Blog

Professional Software for Windows Services / 24×7 Operation


The Top 3 Real-World Problems with Microsoft Srvany

3 Serious Problems with Microsoft Srvany

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:

Notepad Windows Service installed

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:

Srvany running Notepad as a service

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:

Batch file Windows Service installed

When we started the service, Srvany launched the batch file, which started Notepad. So far so good:

Srvany running a Batch File as a service

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:

  1. 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.

  2. 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.

  3. 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!

Posted in Srvany | Tagged , , | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *