cmd.exe: Show/Set Environment Variable
For introduction, see Windows Environment Variables Tutorial
Windows environment variable names are not case sensitive
Show Single Environment Variable's Value
To show a value of a env var, type
Show All Environment Variables
In Command Prompt (cmd.exe), type
To see all your env vars, type:
To see all env vars starting with “p”, type:
Set Environment Variable for Current Session
To set env var for the current session, use
set var_name=value. WARNING: make sure there's no space around the equal sign. Example:
set xx=5 echo %xx% REM prints 5. (REM is a comment syntax, everything after it is ignored.)
REM prepending a path to the “path” env var set PATH="C:\Program Files (x86)\ErgoEmacs;%PATH%"
Set Environment Variable Permanently in Registry
To set env var permanently, use “setx” command. The “setx” command is part of “cmd.exe” in Windows Vista. Here's a example:
REM example of setting HOME env var setx HOME "C:\Users\mary"
REM example of adding a path setx PATH "C:\Program Files (x86)\ErgoEmacs;%PATH%"
For detail, type
Note: “setx” sets environment variable in in the registry, but does not update the current session. Exit and start a new cmd.exe console to see them.