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.

  • 1
    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
  • 1
    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

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.

  • 1
    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

  • 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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