The Set command is used to display, set, or remove MS-Dos environment variables.
To set an environment variable:
To remove an environment variable:
To display all current environment variables:
|envirovariable||The environment-variable name.|
|string||A series of characters to assign to the variable.|
- To use an environmental variable either from the command line or in a batch file, it must be enclosed in % signs as in %envirovariable%.
- 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).
- If SET is used to assign string to a variable that already exists, the new value replaces the old.
- Environmental variables are stored in memory allocated by Command.com. 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:
- TMP and TEMP
- 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.
- Used to specify the directory containing Win.com - the Dos program that starts installing Win95.
- Used to reference command.com from anywhere.
- Used to specify directories to be included in the search path for executable files.
- Used to specify the Windows directory.
- 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.
Eg. SET COPYCMD=/Y
- Used to change the default listing format by the DIR command by adding the appropriate switches - see DIR for the list.
Eg. SET DIRCMD=/A/P
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".
|Blaster||Creative 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:
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.