The Set command is used to display, set, or remove MS-Dos environment variables.


To set an environment variable:
SET envirovariable=string

To remove an environment variable:
SET envirovariable=

To display all current environment variables:
envirovariableThe environment-variable name.
stringA series of characters to assign to the variable.


  1. To use an environmental variable either from the command line or in a batch file, it must be enclosed in % signs as in %envirovariable%.

  2. Environment variables are typically used in three ways:
    • to assign a path to a variable. Many programs will create such a variable during installation to simplify access to temporary, data, and utility files used by the program. Such programs will automatically modify Autoexec.bat or Config.sys to include a SET line defining the variable.
    • to modify the defaults of a number of Dos commands by assigning the new defaults to Standard Environment Variables (see below).
    • as variables in batch files. Unlike the numbered variables %0 to %9, environmental variables are stored until they are reset or the command interpreter terminates (Window closed).

  3. If SET is used to assign string to a variable that already exists, the new value replaces the old.

  4. Environmental variables are stored in memory allocated by If there is insufficient environment space for a new variable, and error message is displayed. To increase the environment space, see Command (& Exit).

The Standard Environment Variables:

Both used by programs to refer to a directory for temporary files.
Default: TMP=c:\windows\temp; TEMP=c:\windows\temp
Used to specify the starting Dos prompt.
Default: PROMPT=$P$G
Used to specify the directory containing - the Dos program that starts installing Win95.
Default: WINBOOTDIR=c:\windows
Used to reference from anywhere.
Default: COMSPEC=c:\windows\
Used to specify directories to be included in the search path for executable files.
Default: PATH=c:\windows;c:\windows\command
Used to specify the Windows directory.
Default: WINDIR=c:\windows
Used to specify whether the COPY, MOVE, and XCOPY commands should prompt for confirmation before overwriting a file.
To force a prompt before overwriting, COPYCMD is set to /-Y.
To force overwriting without prompting, COPYCMD is set to /Y.
Default: Empty
Used to change the default listing format by the DIR command by adding the appropriate switches - see DIR for the list.
Default: Empty

In addition to the above, many programs will set environmental variables without checking to see if the names are free. These variables are almost like trade names. I suspect it would be considered bad form (if not worse) to distribute a program that set a variable called "Blaster".

Variable NameCompany
BlasterCreative Labs Soundblaster
More to be added!


To establish an environment variable named INCLUDE so that the string "c:\inc" (the "inc" directory on drive c:) is associated with it:
SET include=c:\inc

Once this command has been issued, the string "c:\inc" can be referenced at any time by using the term %include%.

Now, if several batch files are written to process files in the "c:\inc" directory, each reference to "c:\inc" can be made via the variable %include%.

Should the "inc" directory be moved or renamed, the batch files need not be altered: the INCLUDE variable would simply be reassigned to the new directory.

File Details:


This page last revised:
December 9, 1999.