Sometimes I need to do things when the computer starts up or when a user logon. A good way to do that is with a GPO startup script or a GPO logon script.
Prepare GPO to copy files
2. Edit the GPO and go to: Computer Configuration –> Preferences –> Files
3. Right click the white area in the right pane and click New –> File
4. Action = Replace, Source file(s) = “The folder where you have you scripts.”, Destination folder = “The folder where you want to copy the scripts”, Archive = Yes.
5. Mark “Remove this item when it is no longer applied”. Click “Ok”
Then you need to link the policy to a OU.
You have now created a GPO the will copy the scripts to a local folder. The files will be download to the folder again if the user is deleting or changing the files.
Create GPO to run the files
Next we need to create a GPO that run the scripts
To create a Computer startup script
1. For computer startup scripts, go to: Computer Configuration –> Policies –> Windows Settings –> Scripts (Startup/Shutdown)
2. Double click on “Startup” on the right pane
4. Choose the script that you have copied with the 1. GPO that we created and click “Ok”
You have now a script that will run from the C drive every time the computer starts
To create a User logon script
1. For user login scripts, go to: User Configuration –> Policies –> Windows Settings –> Scripts (Logon/Logoff)
2. Double click on “Logon” on the right pane
4. Choose the script that you have copied with the 1. GPO that we created and click “Ok”
You have now a script that will run from the C drive every time a user is logging on.
I normally I add a delay in the scripts. Because then I sure that the computer have a network connection. In case the scripts needs to pull some setting or other stuff from the network.