Search

Configuring logon/logoff and startup/shutdown scripts


Within Group Policy, users can be configured with logon/logoff scripts and computers can be configured with startup/shutdown scripts.

Different scripting languages can be used. Traditional .bat or .cmd scripts, VBScript (.vbs files), or JavaScript (.js files) can be used write logon/logoff and 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.

Sample VB Script out put

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.

Default Domain Policy Scripts Logon/Logoff

2) In Logon Properties, click Add.

Logon Script Properties

3) In Add a script dialog box, click Browse.

Logon Script Add a Script dialog box

4) Copy and paste the script file you created before here. Select the script and click Open.

Logon Script Browse

Logon Script Browse with script

5) Click OK in Add a Script dialog box.

Logon Script Add a Script with script

6) Click OK in Logon Properties to finish and exit.

Logon Script Properties with Script

Related Tutorials