Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

How can I turn a given normal application into a Windows service under Windows XP?

EDIT: This is a server application, so it has no GUI and does not require any input or output.

share|improve this question
3  
You should take this question to StackOverflow since it deals with development. –  Jeff May 25 '09 at 22:14
3  
Not really. Running programs as a system service is fairly sysadmin-y, and as the answers below show, don't involve what we'd call programming or development. –  jldugger May 25 '09 at 22:40
2  
You can't turn any application into a Windows Service. It has to implement specific routines so SC knows how to communicate with it. Sure you can create the service given the instructions below but that does NOT mean it will run. ex. do this on Windows XP sc.exe create "Foo Service" binPath= "%SystemRoot%\system32\notepad.exe" this creates fine but then try to run it SC Start "Foo Service" [SC] StartService FAILED 1053: The service did not respond to the start or control request in a timely fashion. –  Jeff May 26 '09 at 0:57
    
@JD (first comment) - Which is something I could not possibly have known beforehand. It doesn't -seem- like a StackOverflow question to me, and it probably won't to other people either. (second comment) - Why not post that comment as an answer? It definitely contains useful information. –  Lucas Lindström May 26 '09 at 4:57
1  
Definitely seems like a serverfault question to me. –  Wayne Koorts May 26 '09 at 20:40

4 Answers 4

up vote 12 down vote accepted

You can use SC to create user defined services. This command will create a service:

sc.exe create "Service Name" binPath= "C:\Your Program.exe"

Note there must be a space between binpath= and the program location.

To Delete the service use:

sc.exe delete "Service Name"
share|improve this answer
1  
Putting a normal program into use as a service like this is asking for trouble. If it is a gui program, forget it. You'll never see the screen. If it's a console program it cannot rely on the user to enter anything and no output sent to the screen will be seen. As JD suggested, asking on StackOverflow may yield better long term results. –  Brad Bruce May 26 '09 at 0:54
    
Use this answer in conjunction with Oleksandr's SRVANY.EXE answer below. This will allow you to start/stop the application like a service from the Windows services manager. –  Rob Penridge Dec 29 '11 at 18:31

Use SRVANY.EXE from Windows * Resource Kit

For Cygwin applications Use cygrunsrv (NT/W2K service initiator)

share|improve this answer

Also, once you successfully started your normal application as a service, I would suggest to test how the application behaves when you log off.

Some applications (old ones?) don't like receiving the message that is sent when logging of or shutting down the computer.

share|improve this answer

FireDaemon is another option for doing this.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.