Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I come from a unix background, and need to do this on Windows Server 2003.

Basically I have a command line process that I start from the windows cmd.exe. I want to achieve the following:

  1. Make this process start on Windows boot by default, without having a user need to log in to start it.

  2. Have a desktop icon that can restart this background process (in case it crashes). So something like a 'nohup mycommand &' on *nix

share|improve this question
Is this a domain connected pc? – KronoS Jan 26 '11 at 20:13
@kronos, i log on via remote desktop via my mac book pro – hvgotcodes Jan 26 '11 at 20:33
I was thinking that this would be better over at ServerFault, but since you don't know what it is... then there's no need :) – KronoS Jan 26 '11 at 20:35
@kronos, lol should be applicable here too though right? – hvgotcodes Jan 26 '11 at 21:38
Yes you are good – KronoS Jan 26 '11 at 21:45
up vote 7 down vote accepted

Running at boot

Turn your process into a Windows Service using the sc command. Basic syntax:

sc create NewServiceName binpath= c:\windows\system32\newserv.exe

Note the space after binpath=. Once you create the service you can configure it to run automatically like any other service. If you're unclear on that, go to the start menu and choose Run. Enter services.msc into the window that opens. This will open the services snap-in in the Microsoft Management Console. From here you should be able to find your service listed (among many others) and set it to run automatically using the gui tools. You could also make this part of your sc create command, but for a novice it's likely much easier to just get the darn thing created and then use the gui tools to set it up the way you want.

One final caveat is to make sure you run this with an account that has the appropriate permissions. The Service or System accounts are best, but sometimes you need something different.

Restarting on demand

A little batch (*.bat) file will do the trick:

sc stop NewServiceName
sc start NewServiceName
share|improve this answer
Nice explanation! – BloodPhilia Jan 26 '11 at 20:24
@joel will try this thanx – hvgotcodes Jan 26 '11 at 21:39
@joel - finally getting around to this. what if the command i use from the command line is 'java -jar thewar.war'? would that go in the binpath with the quotes? – hvgotcodes Feb 2 '11 at 19:12
I think you'd have to wrap the command in a .bat file and use the .bat file as the binpath – Joel Coehoorn Feb 2 '11 at 20:11
@joel, is that just a file with .bat on the end with the one line? – hvgotcodes Feb 2 '11 at 20:25

Make a service out of your process that runs under Local System. Then, make a batch script on the desktop to start and stop the service.


Here's some links:
Running a program as a service
Managing services from the command-line
Making a batch script

share|improve this answer
I don't think the OP knows what you mean, considering he's actually a *nix guy. Can you explain how to accomplish that? – BloodPhilia Jan 26 '11 at 20:08
I don't think the downvote was necessary. The answer's not wrong. I figured he could Google it and get more comprehensive information that I could provide in this answer. I will add links in the edit... – CamronBute Jan 26 '11 at 20:13
The point of Super User (for the most part) is to present a solution that is complete... not always a hint that someone still has to do research in... – KronoS Jan 26 '11 at 20:19
Simply linking just adds link rot to the site. Read Joels answer that is a proper well written answer: he used links but only as sources after quoting said sources. – Not Kyle stop stalking me Jan 26 '11 at 20:23
@Kronos @Kyle Amen. – BloodPhilia Jan 26 '11 at 20:25

On the 2003 Server, open a Local computer Policy snapin in MMC. Expand Computer Configuration-Windows Settings and then open Scripts (Startup/Shutdown) Open Startup and you can add your script there. It should stored be in the sysvol share.

You can also create a shortcut to this script on the desktop

share|improve this answer

Your Answer


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.