How to create, display, and use DOS environmental variables from batch files and the command line. Includes PATH, PROMPT, and PROMPT meta-strings as well as a technique to expand the DOS environment using SHELL.
The DOS environment is a reserved segment of primary memory called the Master Environment Block. The environment is used to store system information in the form of environmental variables, or environmental strings.
Environmental variables are available to the operating system, batch files, and application programs and are used to modify the behavior of DOS commands and application programs, or to provide them with additional information.
To display the contents of the DOS environment, type SET at the DOS prompt and hit the Enter key.
A copy of the environment can be placed in a text file by
From the command line, the command used to create a new environmental variable, or to change
the value for an existing one, is:
From within a batch file, use the form:
If it finds that variable it will look for the command in all of the places which are listed after the PATH variable, each one separated from the next by a semicolon.
To append a new location to the existing PATH from the command line, use this form:
The DOS prompt is the operating system's signal that it is ready for a command. The default DOS prompt is the letter of the current drive only. Use the SET PATH command in AUTOEXEC.BAT to modify the DOS prompt to provide additional information.
The following meta-strings can be used in addition to regular
|Meta Symbol||Translates to|
|$c||( (left parenthesis)|
|$f||) (right parenthesis)|
|$g||> (greater than symbol)|
|$l||< (less than symbol)|
|$q||= (equal sign)|
|$_||Begin new line on screen|
|$$||$ (dollar sign)|
The prompt displayed by DOS as a result would look like this:
COMMAND.COM is loaded into different parts of high and low memory. Those parts which control internal commands and batch files are not needed when an application is running and the application may overwrite them.
When the application terminates and control is returned to DOS, however, those parts of DOS must be re-loaded into memory from disk. This takes a considerable amount of time on a floppy system.
To speed up the process, create a 40K RAMDISK, copy COMMAND.COM there, and use
the COMSPEC command to specify where DOS should look for COMMAND.COM on disk.
This is usually accomplished within AUTOEXEC.BAT:
The DOS environment can be used as a general purpose memory pool accessible by all programs and batch files.
Customizing a text editor (ED=PC-Write):
Pointing a database program to its data files (AE=AE:Address):
The default shell for DOS is COMMAND.COM. However, the SHELL command
allows us to specify a different (3rd party) command processor to be used.
The default size of the DOS environment is 160 characters. Often this is insufficient to accommodate the total environmental variables in use. To expand the environmental space:
Under DOS 3.0 and 3.1:
Under DOS 3.2 and up:
(The /p switch instructs COMMAND.COM to run AUTOEXEC.BAT)