How do I make an exe into a service on Windows?

I recently made an application that has multiple parts. One of the parts is a networking tool - it always starts with the OS, and it never displays any sort of message. It does, however, start an incredibly irritating console, which is impossible to get rid of without closing the program itself (please just accept this one as given). I have decided to work around this problem by starting the program (it's a *.exe) as a service, thus stopping it from showing up at all. As the application will be distributed to various computers (hence the need for a networking tool in the first place). I need a way to make this program install as a service (so, I don't really want answers that tell me to go through a series of menus on the Control Panel or download a 3rd-party application that has to stay on whichever computer the service will run on). How can I do this?

1

4 Answers

In the Windows NT Resource Kit, Microsoft provides a tool called srvany that will run an .exe as a service. A tool that works better than that is The Non-Sucking Service Manager (nssm).

I have used nssm to turn a python console executable that's a web server into a service that runs when the system boots successfully.

3

Microsoft has compiled the steps to create a Windows Service and install it on a remote computer at this page. There are too many step to outline here. There are additional links to assist you with potential problems.

In my experience NSSM is the best tool for this purpose. Firstly it's open source and secondly it support all versions of Windows. Another good thing about this tool is that is monitors the service, if it fails it restarts the service automatically. Here's a detailed guide on how to use it.

1

There are many third-party tools to run a normal Windows executable as a service.

Bitsum authored such a utility, command line only, called MakeService (now in limited distribution due to abuse).

They are able to do this by using a service stub that then launches the normal Windows executable. That service stub can then control the launched process as necessary in response to start, stop, etc.. service commands.

However, if your application has any interactivity with the user, then you will encounter system service session isolation in NT6+.

It's sad that we had to discontinue instant download of this freeware utility, but we will still distribute it to those who have legitimate needs. It is available in 32-bit and 64-bit x86 native.

I am sure there are other similar utilities, including Microsoft's srvany.exe in the Windows Resource Kit, as the accepted answer recommends. It does the same thing as our MakeService did/does.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like