Environment Variables

Environment Variables are string variables containing information that an operating system uses to control services and applications.

What is Environment Variables?

String variables containing information that an operating system uses to control services and applications. The PATH and TEMP variables used in the autoexec.bat file in MS-DOS were early examples of environment variables. Microsoft Windows NT and Windows 2000 offer a more extensive selection.

For example, environment variables for Windows NT include the following:

  • System (predefined) environment variables such as USERNAME, USERDOMAIN, WINDIR, and HOMEPATH. These variables are set on the system no matter who logs on and cannot be changed by any user. They specify particular parameters pertaining to the system itself, such as the location of the operating system files. They can be used in logon scripts because they are always present when any user logs on.

    Graphic E-4. Environment variables of Windows NT.

  • User (user-defined) environment variables, such as the path to application files. User environment variables take precedence over system environment variables when the two conflict.
  • Autoexec.bat environment variables, such as those used in path statements.

You can view and specify environment variables in Windows NT and Windows 2000 by using the System utility in Control Panel. Environment variables may be used in logon scripts by enclosing them within percent symbols; for example, %USERNAME% contains the currently logged on user name.

NOTE

The System utility in Control Panel shows only a portion of the system environment variables defined on a system running Windows NT or Windows 2000.