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.
Best Answer
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.