Modifying Environment Variables

Command Prompt gets its environment variables from three sources:

• Any variables set in your Autoexec.bat file x '

• System variables, as recorded in HKLM\System\CurrentControlSet\Control\Session Manager\Environment

• User variables, as recorded in HKCU\Environment

When you log on, Windows scans the Autoexec bat file in the root folder of your boot drive for environment variables initialized with Set statements . System and user variables are both stored in the registry, but you don't need to launch a registry editor to change them . Open System in Control Panel instead . Click Advanced System Settings to get to the System Properties dialog box. Click the Advanced tab and then Environment Variables .

Changes to environment variables made via Control Panel affect your next and subsequent Command Prompt sessions (but not current ones). Changes made via Autoexec.bat are not effective until the next time you log on . In case of conflicting assignments, user variables take precedence over system variables, which take precedence over variables declared in Autoexec.bat. The Path variable, however, is cumulative. That is, changes made in any venue are appended to any changes made elsewhere

Using Environment Variables 969

Within a given Command Prompt session, you can change environment variables by means of Set statements . Such statements affect only the current session and any applications (including additional Command Prompt sessions) spawned from the current session.

Predefined Environment Variables

Many of the environment variables you see when you use the Set command are ones that Windows automatically sets with information about your system. You can use these values in batch programs, Doskey macros, and command lines—and if you're a programmer, in the programs you write. The system-defined environment variables include the following:

• Information about your place in the network COMPUTERNAME contains the name of your computer, USERDOMAIN contains the name of the domain you logged on to, and USERNAME contains your logon name

• Information about your computer PROCESSOR_ARCHITECTURE contains the type of processor (such as "x86"), and PROCESSOR_IDENTIFIER, PROCES-SOR_LEVEL, and PROCESSOR_REVISION provide specific information about the processor version

• Information about Windows SystemRoot contains the drive and folder in which Windows is installed; SystemDrive contains only the drive letter.

• Information about your programs When you type a program name (to start the program) without typing its path, Windows looks first in the current folder. If the program isn't located in the current folder, Windows looks in each folder listed in the Path variable.

• Information about your file locations The APPDATA, LOCALAPPDATA, PUBLIC, and USERPROFILE variables each contain a pointer to a folder that many applications use as a default storage location for documents and other data files .

• Information about the command prompt PROMPT contains codes that define the appearance of the command prompt itself. (For details, type prompt /? at the prompt.)

Was this article helpful?

0 0
Digital Cancers

Digital Cancers

Get All The Support And Guidance You Need To Be A Success At Protecting Your PC. This Book Is One Of The Most Valuable Resources In The World When It Comes To The Damaging Facts About Computer Viruses.

Get My Free Ebook

Post a comment