Windows 2008 startup script will not run?
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
Related videos on Youtube
user2751502
Updated on September 18, 2022Comments
-
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 underWindows Settings/Scripts (Startup/Shutdown)/Startup
when I runrsop.msc
, but the script is not being executed. The "Last Executed" column inrsop
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 calledc:\scripts\startup.bat
, and works fine if I run it by hand.-
Rex over 11 yearsWhat NTFS permissions are assigned to the c:\temp and c:\scripts folder and to the batch file itself?
-
MDMarra over 11 yearsAre you going to chop the local group policy editor into little pieces and boil it in oil? ;)
-
user2751502 over 11 yearsIt 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 over 11 yearsRex: I'll update the question with ACLs in a moment; waiting for a service pack to apply...
-
MDMarra over 11 yearsYou 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 over 11 yearsYou 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 over 11 yearsI 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 over 11 yearsI believe that items added to this key are run after someone logs in, not at system startup. Please correct me if I'm wrong.