Microsoft Windows XP Professional Administrators Guide

Windows XP Professional stores most of its configuration settings in the Windows XP registry. Some of this information is made available as system environment variables. Environmental variables are generated from information that is collected from a number of different sources, including:

There are two types of environment variables, user and system. User environment variables are user-specific, meaning that they may be set to different values for each user of the computer. System variables, on the other hand, affect the entire computer and every user of the computer. Changes made to environment variables are actually changes made to the Windows XP registry. Changes made to user environment variables are not effective until the user logs off and back on again. Changes to system variables are not effective until the computer is restarted.

Any changes made to environment variables are permanent, meaning that they survive across system restarts and remain in effect until changed or deleted.

Users can modify their own user variables. Only administrators can modify system variables.

Access to user and system variables is provided from the System Properties dialog. The following procedure outlines the steps involved in displaying these variables.

  1. Click on Start, right-click on My Computer, and select Properties. The System Properties dialog appears.

  2. Select the Advanced property sheet.

  3. Click on Environment Variables. The Environment Variables dialog appears, as shown in Figure 12.19.

    Figure 12.19: Displaying user and system variables

  4. The top portion of the dialog displays user variables. The bottom portion of the dialog displays system variables.

By default, two user environment variables are established for every user.These are:

A number of system variables are automatically established and affect every user of the computer. These system variables include:

The following procedure outlines the steps involved in modifying an environment variable.

  1. Open the Advanced property sheet on the System Properties dialog and click on Environment Variables. The Environment Variables dialog appears.

  2. To modify a user or system variable, select the variable and click on the Edit button in the user or system variable section, depending on the type of variable selected.

  3. The Edit User Variable or Edit System Variable dialog appears.

  4. To change the variable's name, type a new name in the Variable name field.

  5. To change the value assigned to a variable, type a new value in the Variable value field.

  6. Click on OK.

  7. Click on OK twice to close the Environment Variables and System Properties dialogs.

Log off and back on again in order for a change to a user variable to take affect. For a change to a system variable to take effect, the computer must be restarted.

The following procedure outlines the steps involved in creating a new environment variable.

  1. Open the Advanced property sheet on the System Properties dialog and click on Environment Variables. The Environment Variables dialog appears.

  2. To create a new user or system variable, click on the New button in either the user or system section.

  3. The New User Variable or New System Variable dialog appears.

  4. Type the name of the new variable in the Variable name field.

  5. Type the value to be assigned to the new variable in the Variable value field.

  6. Click on OK.

  7. Click on OK twice to close the Environment Variables and System Properties dialogs.

The new environment variable will appear in the list of user or system variables but is not effective until the next login session or a restart is performed.

Deletion of environment variables should be performed with great care. No confirmation is required when deleting an environment variable, and the effect of removing it will not be known until the user's next login session or the next time the computer is restarted. The following procedure outlines the steps involved in deleting an environment variable.

  1. Open the Advanced property sheet on the System Properties dialog and click on Environment Variables. The Environment Variables dialog appears.

  2. To delete a user or system variable, select the variable and click on the Delete button in the user or system variable section, depending on the type of variable selected.

  3. Click on OK.

  4. Click on OK twice to close the Environment Variables and System Properties dialogs.

Not every variable is visible from the Environment Variables dialog. By executing the SET command at the Windows XP command prompt, additional variables can be displayed. For example, Figure 12.20 shows a typical list of variables displayed from the command prompt.

Figure 12.20: Displaying variables from the Windows XP Professional command prompt

The SET command is especially important to administrators who develop Windows scripts because it allows scripts to create temporary variables that can be referenced throughout the script.

Note 

More information on Windows scripting and the use of the SET command is available in Chapter 14, "Shell Scripting and the WSH."

Категории