2012-11-30

How to set environment variables in Windows?

Environment variables are values that, once set, become available to all programs running in the computer.

The value of an environment variable can be used like this: %name%. Typically, environment variables are used to specify program paths and settings.

Some environment variables are set by Windows.
%ProgramFiles% holds the value of the program folder (english Windows: C:\Program Files; portuguese Windows: C:\Programas).
%UserName% holds the user name of the user in session.
%UserProfile% holds the home folder of the user in session.

One of the most used environment variables is PATH, that specifies where the operating system looks for programs.
Folders are separated by the ; character.

To see the value of PATH, execute ECHO %PATH% in the console.
Also, the SET command can print and set environment variables.


To set environment variables permanently on Windows, go to Computer System Properties, Advanced, Environment Variables. The following screen-shots illustrate this procedure for Windows 7.




Environment variables can be defined for the current user (user) or for all users (system).


The new settings only take effect for new consoles.

No comments: