Name
set
Synopsis
Display, assign, or remove environment variables.
Syntax
set [variable
[=[string
]]]
set /pvariable
=[promptstring
]
set /a expression
Description
The environment is a small portion of memory
devoted to the storage of a few values called environment variables.
set
is used to manipulate environment variables
from the command line, but since the Command
Prompt’s environment is reset when its window is
closed, the usefulness of set
is fairly limited.
To affect more permanent changes to environment variables, go to
Control Panel → System
→ Advanced tab
→ Environment variables.
This window should be fairly self-explanatory; the variables in the
upper listing are for the current user and variables in the lower
listing apply to all users. Some environment variables, such as the
Temp
user variable, are assigned with respect to
other variables, like this:
%USERPROFILE%\Local Settings\Temp
where %USERPROFILE%
(note the percent signs
(%)
on either side) signifies the
USERPROFILE
variable, which represents the path of
the current user’s home directory. See “path”, earlier in this chapter,
for another example of this usage.
In addition to providing a simple means of interapplication communication, environment variables are also useful for storing data used repeatedly in a batch file (see Section 6.5, later in this chapter).
Type set
without options to display all of the
current environment variables. Type set
with only a variable name (no equal sign or value) to display a list of all ...
Get Windows XP in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.