Social Enterprise

Understanding environment variable precedence in Windows XP

Have you ever set an environment variable in the Autoexec.bat file and then discovered that the variable has a different value than the one you specified? This is because the variable was probably overridden by the same setting in the Environment Variables dialog box. Discover how to avoid such problems.

Stay on top of the latest XP tips and tricks with our free Windows XP newsletter, delivered each Thursday. Automatically sign up today!

Many IT pros still use the Autoexec.bat file to set environment variables, which is fine in most cases. However, if you set an environment variable in the Autoexec.bat file and then discover that the variable has a different value than the one you specified, the variable was probably overridden by the same setting in the Environment Variables dialog box.

This is because during the startup procedure Windows XP searches the startup files and processes the environment variable settings in the following order:

  • Autoexec.bat files
  • System Variables
  • User Variables

Therefore, if you set the same environment variable in the Autoexec.bat file and in the System Variables section, the value assigned in the System Variables section will override the value assigned in the Autoexec.bat file.

To avoid these types of problems, you might want to get into the habit of setting environment variables in the Environment Variables dialog box. Here's how:

  1. Right-click My Computer and select Properties to open the System Properties dialog box.
  2. Select the Advanced tab and press the Environment Variables button.

From the Environment Variables dialog box, you can set user-specific variables or system-specific variables by pressing the New or Edit buttons and then selecting OK.

About Greg Shultz

Greg Shultz is a freelance Technical Writer. Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry.

Editor's Picks