Run a Windows application as a service?

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

Use case: The northern version of the 64-bit version of Microsoft memcached works as a general application. I would like to use it in a Windows 2003 or 2008 service so that I can start / stop / restart / etc. Via the standard interface.

+3
source share
3 answers

The Windows Resource Kit has any executable file srvany.exethat can be used as described here to run basically any exe as a service. The setup is a bit confusing (registry editing is required), but it should work for most things that can run as user applications.

+5
source

If you cannot change the application, there are a bunch of "run as a service" wrappers.
I used cygrunsrv.exe, I think it works with executables without cygwin.

+1
source

If you cannot change the code, you cannot directly launch the application as a service. However, it shouldn't be difficult to make a Win32 service - it all revolves around calling a single api: StartServiceCtrlDispatcher . In response to the commands from the service control manager, your wrapper service created CreateProcess, etc. In memcached application.

0
source

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


All Articles