-------------------------- MS-DOS v6.22 Help: Set --------------------------
<Notes> <Examples>                                               <Index>


Displays, sets, or removes MS-DOS environment variables.

You use environment variables to control the behavior of some batch files
and programs and to control the way MS-DOS appears and works. The SET
command is often used in the AUTOEXEC.BAT or CONFIG.SYS files to set
environment variables each time you start MS-DOS.


    SET variable=[string]

To display the current environment settings, use the following syntax:



    Specifies the variable you want to set or modify.

    Specifies the string you want to associate with the specified variable.

Related Commands

For information about setting environment variables that MS-DOS uses to
control its own operations, see the <PATH>, <PROMPT>, <SHELL>, and <DIR>


<Syntax> <Examples>


Displaying the current environment settings

When you type the SET command alone, MS-DOS displays the current environment
settings. These settings usually include the COMSPEC and PATH environment
variables that MS-DOS uses to help find programs on disk. PROMPT, DIRCMD and
COPYCMD are some other environment variables that MS-DOS uses. For more
information about DIRCMD, see the <DIR> command.

Using parameters

When you use a SET command and specify values for both variable and string,
MS-DOS adds the specified variable value to the environment and associates
the string with that variable. If the variable already exists in the
environment, the new string value replaces the old string value.

If you specify only a variable and an equal sign (without a string) for the
SET command, MS-DOS clears the string value associated with the variable (as
if the variable is not there at all).

Using SET in batch files

When creating batch files, you can use the SET command to create variables
and use them in the same way as you would the numbered variables %0 through
%9. You can also use the variables %0 through %9 as input for the SET

Calling a SET variable from a batch file

When you call a variable value from a batch file, you must enclose the value
with percent signs (%). For example, if your batch program creates an
environment variable named BAUD, you can use the string associated with BAUD
as a replaceable parameter by inserting %BAUD% on the command line.

Effect of SET on environment space

After you use a SET command, MS-DOS might display the following message:

    Out of environment space

This message means the available environment space is insufficient to hold
the new variable definition. For information about how to increase the
environment space, see the <COMMAND> command.

Using the COPYCMD environment variable

You can set the COPYCMD environment variable to specify whether you want the
COPY, MOVE, and XCOPY commands to prompt you for confirmation before
overwriting a file, whether issued from the command prompt or a batch file.

To force the COPY, MOVE, and XCOPY commands to prompt you before overwriting
in all cases, set the COPYCMD environment variable to /-Y. To force these
commands to overwrite in all cases without prompting you, set the COPYCMD
environment variable to /Y.

Typing any of these commands with the /Y or /-Y switch overrides all
defaults and the current setting of the COPYCMD environment variable.


<Syntax> <Notes>


To set an environment variable named INCLUDE so that the string C:\INC (the
INC directory on drive C) is associated with it, type the following

    set include=c:\inc

You can then use the string C:\INC in batch files by enclosing the name
INCLUDE with percent signs (%). For example, you might include the following
command in a batch file in order to display the contents of the directory
associated with the INCLUDE environment variable:

    dir %include%

When MS-DOS processes this command, the string C:\INC replaces %INCLUDE%.

Another possible use for the SET command is in a batch program that adds a
new directory to the PATH environment variable, as the following example

    @echo off
    rem ADDPATH.BAT adds a new directory
    rem to the PATH environment variable.
    set path=%1;%path%


<Top of page>
Last update: December 07, 2002 14:45 by
Content © 1997 Microsoft Corporation
All else © 2000-2005