i
L ;
SET
r
SET
[name
= [string]]
I
Chapter 6 /
Command
Reference
Internal
Sets
an
environmental variable equal to a string.
Parameters
name is
the
environment variable to assign
to,
string. name
cannot be numeric.
string is
the
string
you
are
naming
in
the
environment.
If
you
omit
the
string
parameter,
SET removes the variable name from
the
environment. string cannot be numeric.
If
you omit
all
parameters, SET displays
the
current
environ-
ment variables
and
their
settings.
L
~
I :
r-,
l .
r
!"""
[ ,
I'
l
I'
I
Notes
and
Suggestions
• This command is useful only
in
programs
you
have written.
• MS-DOS reserves a
part
of memory
for
environment variables.
If
you use a name
that
already exists
in
the
environment, SET
replaces
the
old
value of name
with
the
new string.
•
You
use
SET
to
its
greatest
advantage
if
you
have several
batch files
that
use
the
same string. For example, suppose
you
have several
batch
files
that
contain %filename%. One
might
contain
the
command:
type
7.filename7.IENTERI
Another
might
contain
the
command:
cop
y
a:
7.
f i 1e na me
7.
b:
I
ENTER
I
Note:
Within
the
batch
file commands, the
string
is
enclosed by percent signs.
Within
the
SET
com-
mand,
it
is not.
The first
time
you
run
all
the
batch files, you may want to
substitute
Myfile
for
filename.
To
do
this, use
the
SET
com-
mand before you begin. Type:
set
filename=myflle
I
ENTER
I
165