Windows 2008 startup script will not run?

9,389

Solution 1

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.

Solution 2

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

You can add your script there if it is not already

http://www.akadia.com/services/windows_registry.html

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

Share:
9,389

Related videos on Youtube

user2751502
Author by

user2751502

Updated on September 18, 2022

Comments

  • user2751502
    user2751502 almost 2 years

    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.

    • Rex
      Rex over 11 years
      What NTFS permissions are assigned to the c:\temp and c:\scripts folder and to the batch file itself?
    • MDMarra
      MDMarra over 11 years
      Are you going to chop the local group policy editor into little pieces and boil it in oil? ;)
    • user2751502
      user2751502 over 11 years
      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.
    • user2751502
      user2751502 over 11 years
      Rex: I'll update the question with ACLs in a moment; waiting for a service pack to apply...
    • MDMarra
      MDMarra over 11 years
      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.
  • MDMarra
    MDMarra over 11 years
    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.
  • user2751502
    user2751502 over 11 years
    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.
  • user2751502
    user2751502 over 11 years
    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.