views:

126

answers:

3

What is the cleanest, most reliable way to run a Windows application as a service without touching its code?

Use case: NorthScale's 64-bit Windows version of memcached runs as a generic application. I'd like to stick it into a Windows 2003 or 2008 Service so I can start/stop/restart/etc it through the standard interface.

A: 

If you can't modify the app there are a bunch of 'run as service' wrappers.
I have used cygrunsrv.exe, I think it works with non-cygwin executables.

Martin Beckett
A: 

Well, given this is Stackoverflow, not serverfault or superuser, I'm going with a programming related answer:

If you can't change the code then you cannot directly run the app as a service. However it should not be difficult to Make a Win32 service - it all revolves around calling one api: StartServiceCtrlDispatcher. In response to commands from the service control manager your wrapper service would CreateProcess etc. on the memcached application.

Chris Becke
+2  A: 

The Windows Resource Kit has any executable, srvany.exe that can be used, as described here, to run basically any exe as a service. The setup is a little convoluted (requires a registry edit), but should work for most things that can be run as a user applicaiton.

ig0774
Works perfectly, thanks.
sh-beta