set(CMD) 19 June 1992 set(CMD) Name set - display, set, or remove MS-DOS environment variables Syntax set [variable=[string]] To display the current environment settings, use the following syntax: set Description 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 file to set environment vari- ables each time you start MS-DOS. Parameters variable Specifies the variable you want to set or modify. string Specifies the string you want to associate with the specified variable. Notes Displaying the current environment settings When you type the set command alone, MS-DOS displays the current environ- ment settings. These settings usually include the COMSPEC and PATH environment variables that MS-DOS uses to help find programs on disk. PROMPT and DIRCMD are two other environment variables that MS-DOS uses. For more information about DIRCMD, see the dir(CMD) 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 string with that variable. If 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 vari- able (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 vari- ables 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 command. 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(CMD) command. Examples 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 command: 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 fol- lowing 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 exam- ple shows: @@echo off rem ADDPATH.BAT adds a new directory rem to the PATH environment variable. set path=%1;%path% set Related commands For information about setting environment variables that MS-DOS uses to control its own operations, see the path(CMD), prompt(CMD), shell(CMD), and dir(CMD) commands.