Manage Learn to apply best practices and optimize your operations.

Using Group Policy Objects to manage script execution

Learn how Group Policy can be used to specify execution parameters for scripts running on your Windows system.

An earlier tip described the group policy object controls used to define the various scripts that are to be run...

on a system at startup or shutdown and for users at logon and logoff. This tip discusses the controls that manage how those scripts are actually executed.

The computer configuration section of a GPO contains the Administrative Templates/System/Scripts folder that contains the controls for managing computer-focused scripts. This folder contains five controls. To understand how to use these controls, you need to keep in mind one important item: by default scripts execute one after the other in a series in the order defined in the Windows/Scripts section of the GPO.

The Run logon scripts synchronously control forces the system to wait until all logon scripts have fully completed their execution before the Windows Explorer interface launches and presents the desktop to the user. This control is disabled by default, which allows the desktop to start while the logon scripts are concurrently executing. This can result in problems in some instances, especially if the user is able to launch an application that relies upon the results of a logon script (such as mapping network drives) quickly. The control in the computer configuration area manages this feature based on the workstation while the same control in the user configuration area manages this feature based on the user account.

The Run startup scripts asynchronously control alters the default synchronous or series execution of startup scripts. Instead, it allows all scripts to launch simultaneously and execute concurrently. If you enable this control, be sure that all scripts are fully independent of each other and don't require the completion of one script to support a function within another.

The Run startup scripts visible and Run shutdown scripts visible controls alter the default execution of scripts from being hidden from the user into a scripting-language specific window displaying the execution and results of the script. In most cases, there is no need for users to view the execution of scripts. The Run logon scripts visible and Run logoff scripts visible controls in the User Configuration section performs the same function but for logon/logoff scripts instead of startup/shutdown scripts.

The Maximum wait time for Group Policy scripts control sets the total amount of time scripts can execute before they are terminated by the system and an error event recorded in the System log. By default the system waits 600 seconds (10 minutes).

The User Configuration section of a GPO contains the Administrative Templates/ System/Scripts folder, and this one contains controls for managing user-focused scripts. There are four controls, but three of them are duplicates or alternates to similar controls in the Computer Configuration section discussed earlier.

The Run legacy logon scripts hidden control alters the default execution of legacy scripts in a visible window to being hidden from the user. Legacy logon scripts are those written for Windows NT 4.0 and earlier.

James Michael Stewart is a researcher and writer for Lanwrights, Inc.

Dig Deeper on Windows systems and network management