Server Fault is a question and answer site for system and network administrators. 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 am trying to get a very simple batch script to run when my Windows 2008 Server (R2) system starts up. I have added the script to the "Startup Scripts" in the local group policy by running gpedit.msc, and I see the script listed under Windows Settings/Scripts (Startup/Shutdown)/Startup when I run rsop.msc, but the script is not being executed. The "Last Executed" column in rsop is empty even after a reboot, and a file that should be created by the script is never created.

At the moment, the entire contents of the script are:

rem Check if this script is running.
date /t > c:\temp\flag

The target directory (c:\temp) exists. The script is called c:\scripts\startup.bat, and works fine if I run it by hand.

share|improve this question
What NTFS permissions are assigned to the c:\temp and c:\scripts folder and to the batch file itself? – Rex Oct 31 '12 at 17:34
Are you going to chop the local group policy editor into little pieces and boil it in oil? ;) – MDMarra Oct 31 '12 at 17:40
It hasn't annoyed me anywhere near as much as the BSD automounter. At this point I assume it's my problem...Windows administration really isn't my strength. – larsks Oct 31 '12 at 17:44
Rex: I'll update the question with ACLs in a moment; waiting for a service pack to apply... – larsks Oct 31 '12 at 17:45
Argh. psexec was giving me weird errors, and replacing the script (rename oldname newname, type newname > oldname) made them go way. After applying SP1, I can't reproduce the problem. MDMarra, if you post your comment re: psexec as an answer I'll accept that one, since it seemed to provide a useful diagnostic.' – larsks Oct 31 '12 at 18:35
up vote 3 down vote accepted

You should grab a copy of psexec and run psexec -s path\to\script.bat. That will run it as System. That's a more accurate manual test than running it as the logged in user, since startup scripts run as SYSTEM.

share|improve this answer
I didn't know about psexec, so that was very helpful. The permissions on the file were odd and when running with psexec I was getting a weird "command not found" sort of error. Re-generating the script seemed to fix things, so I'm chalking it up to a permissions issue. – larsks Nov 1 '12 at 1:32

check the registry key hklm\software\microsoft\windows\currentversion\run

You can add your script there if it is not already

otherwise check permissions on the folder to make sure the system account has write access

share|improve this answer
You should really switch your two points around so that the answer to the actual question is on top and a suggestion for a workaround is second. I'd like to upvote you, since it sounds like an NTFS permission problem, but not if the workaround is the first suggestion. – MDMarra Oct 31 '12 at 17:39
I believe that items added to this key are run after someone logs in, not at system startup. Please correct me if I'm wrong. – larsks Nov 2 '12 at 14:46

To get this to work for me (granted on Windows Server 2012), I had to do the following:

  1. Run gpedit.msc, go to Computer Configuration > Windows Settings > Scripts and double-click Startup
  2. Click Show Files and paste a Shortcut to my script in the folder that pops up
  3. Back in the the Startup Properties dialog, click Add then Browse and select your shortcut.
  4. Click OK and reboot.

The pasting of the shortcut was the critical bit. Browsing to a location outside of the Scripts/Startup folder resulted in nothing working.

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.