Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 have an Amazon EC2 machine (Windows Server 2003 R2) where I want to run a script (.bat file) when the Windows Server 2003 R2 machine boots up. This need to run BEFORE any user logs in. Ideally I'd like to extend the same work-around on my Windows Server 2008 R2 instances too - but Windows Server 2003 R2 is critical for me as of now.

Purely as FYI, the .bat file updates the DDNS records so the EC2 machine doesn't need to consume static IPs.

share|improve this question

Use GPedit.msc

Go under Computer Management/Windows/Scripts/Startup.

Place your script there.

Note that the script will run under the LOCAL SYSTEM account.

You can use the same method on your 2008R2 instances also.

share|improve this answer
up vote 2 down vote accepted

Thanks surfasb. Up voted your answer but for some reason it didn't actually work. (user account permissions maybe?). Basically I rebooted the machine and it didn't trigger it.

So I set it up as a proper scheduled task (system scheduler) and set the event as "at startup". Upon the 2nd reboot my batch file kicked off just fine. Didn't investigate this beyond that, but I guess we now have two solutions!

share|improve this answer

The program can be installed as a service:

If a bat file, it must first be converted to an exe or AutoExNT from the Win2k3 resource kit can be used.

Also, once converted nssm makes it real easy to install a service. Just nssm install <servicename>

share|improve this answer
The article explicitly states "but not for batch files." – BillP3rd Dec 2 '12 at 7:15
Wups, thanks for pointing that it. Updated my answer. – reflexiv Dec 2 '12 at 15:29

instead of running a .bat file rename it to .cmd and test it. There is a difference between .bat and .cmd and how Windows interprets the batch commands. For more info Google differences between .bat and .cmd. VBScript will also work or a VBScript to fire off your old batch file.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .