Within Group Policy, users can be configured with logon/logoff scripts and computers can be configured with startup/shutdown scripts.
The logon/logoff and startup/shutdown scripts can be used for different purposes. Startup/shutdown scripts can be used to perform system related task like maintenance, backups, virus checking etc. Logon/logoff scripts can be used to perform user related tasks like launching applications, cleaning up temporary folders, setting up printers, mapping network drives etc.
Users execute the script only at logon or logoff and computers execute the scripts only at startup or shutdown.
To use logon/logoff and startup/shutdown scripts with Group Policy, users must be in the site, domain, or OU linked to a GPO that contains a logon or logoff script. Computers must also be in the site, domain, or OU linked to a GPO that contains a startup or shutdown script.
Following is an example how to configure a logon script. The following is a simple one-line VB script program, which display a welcome message box.
MsgBox "Welcome to your server!", vbExclamation, "Logon Script"
Copy the above line in notepad and save it with a .vbs extension, example first.vbs. When you execute this script by double clicking it, e message box will be displayed as shown below.
Follow these steps to configure logon script.
1) Open the required policy in Group Policy editor. In this example it is Default Domain Policy. Open User Configuration > Windows Settings > Scripts (Logon/Logoff). Right click Logon and select Prpperties from the context menu.
2) In Logon Properties, click Add.
3) In Add a script dialog box, click Browse.
4) Copy and paste the script file you created before here. Select the script and click Open.
5) Click OK in Add a Script dialog box.
6) Click OK in Logon Properties to finish and exit.