How tonstall an executable as a Windows Service

windows 7windows-server-2008windows-service

I have an executable that doesn't require any interaction with the user and I want to install it as a Windows service; what do I need to have and do to make that happen?

  • I didn't write the app; I don't have the source and not willing to have it.
  • It's not a .Net app; can't use InstallUtil.exe
  • I'm on Windows 7 and Windows Server 2008

Best Answer

I don't know about Windows 7, but the SC and SrvAny utilities from the Windows Server 2003 resource kit still worked on Server 2008 the last time I checked; I've used this technique myself to get PDFCreator running as a service on our file/print box:

  • Grab "srvany.exe" from the Server 2003 Resource Kit and copy it to your Server 2008 box.

  • Use "sc" to create a new service that launches "srvany":

sc create NewService binPath= C:\Windows\System32\srvany.exe DisplayName= "My Custom Service".

(Those spaces between the equal sign and the value are actually required by SC. No, I don't know why either.)

  • Use Regedit to create a key called "Parameters" in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NewService\Parameters). Inside that key, create a string value called "Application" and enter the full path to the application you are wanting to run as a service.

  • Cross fingers, start service.