Create a group policy object (GPO) to run a script only once

Issue

You might need to execute a command only once. Here is a trick to do so on every computer at user logon. This script has been tested to run command with standard user privileges.

Solution

Create your script and store it somewhere accessible to the users. Personally, I would advise to store it where the logon scripts are. Otherwise, please create a share folder that is accessible in Read Only by the required users.

Create a new Group Policy Object on your Domain Controller and then Go to

User Configuration > Windows Settings > Scripts (Logon / Logoff)

Double click on Logon.

Click on Show Files…

Paste your script into the location

Press and maintain SHIFT key on your keyboard and right click on the file. Select Copy as path.

Go to

Preferences > Control Panel Settings > Scheduled Task

Right click and select

New > Immediate Task (At least Windows 7)

Enter the name of your script

Go to Actions and Click New…

Paste the script location you’ve copied earlier and press OK

Go to Common, tick Apply once and do not reapply and press OK.

Source

https://wiki.ledhed.net/index.php?title=Run_Command_Once_with_GPO_(instead_of_Logon/Startup_Script)

Was this post helpful?