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.

sh-beta
  • 3,809
  • 7
  • 27
  • 32

3 Answers3

5

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
  • 39,669
  • 3
  • 55
  • 57
1

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
  • 94,801
  • 28
  • 188
  • 263
0

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.

yhw42
  • 3,334
  • 2
  • 27
  • 24
Chris Becke
  • 34,244
  • 12
  • 79
  • 148