2.11. Viewing and Setting Environment Variables
You want to view the current environment variables or create new ones.
Using a graphical user interface
From the Control Panel, open the System applet.
Select the Advanced tab.
Click the Environment Variables button.
Click the New button under the User variables or System variables box depending on whether you want to create an environment variable that is visible only to the currently logged-on user or system-wide.
Enter the variable name and value and click OK until all windows are closed.
The new variable(s) will not be available in any CMD windows that are currently open. You'll need to close and reopen any CMD sessions in which you want to use the new variable(s).
Using a command-line interface
To view environment variables, run the set command. You can also view a subset of environment variables by running set and specifying the first letters of the variable(s). This command displays all environment variables that begin with USER:
> set user
You can use the wmic utility to print environment variables on a remote system:
> wmic /node:"
<ServerName>" environment list full
You can print the value of an environment variable using echo:
> echo %systemroot%
To set an environment variable for use in the current CMD
session, use the set command.
The following command sets the
FOOBAR environment variable:
> set FOOBAR=test
FOOBAR will be valid only for the life of the CMD session you set it in. If you need to create a permanent ...