home *** CD-ROM | disk | FTP | other *** search
- ENVIRONMENT VARIABLES
-
- Environment variables which have previously been defined in the DOS
- environment space by the SET command or other programs can be referenced in
- BATCH files by prefixing and suffixing the defined name with a per cent sign
- (%). If a variable is SET during the execution of a BATCH file, the value
- is preserved until the variable is reSET, except in the case of a BATCH file
- executed by COMMAND /C or CALL. All DOS environment space changes made by
- such a BATCH file are lost when it EXITs.
-
- Every occurrence of %NAME% in a BATCH file will be replaced by the value of
- the variable NAME. The name of a variable may appear anywhere in the BATCH
- file, and can be used to insert filenames, commands to be executed, or
- strings to be searched for in the BATCH file. The value can have spaces. The
- value assigned to the variable can have |, <, or > in it, if the value is
- surrounded by double quotes (") when SET, but will not be interpreted as
- piping or redirection when referenced in a BATCH file.
-
- An environment variable COMSPEC is automatically created in the DOS
- environment space to save the program name from the SHELL line in the
- CONFIG.SYS file. The PATH and PROMPT commands also automatically create
- variables, named PATH and PROMPT. The APPEND /E command creates a variable,
- named APPEND.
-
- NOTE: If you ever want to include the character '%' in a batch file, in a
- message to be displayed on the screen for example, you need to include it
- twice to get it displayed once. For example, if the variable COMPLETENESS
- had been set to 100, the command
-
- ECHO processing %COMPLETENESS%%% complete
-
- in a batch file will display the message
-
- processing 100% complete
-
- on the screen.