Article ID: 121170 - Last Review: September 30, 2003 - Revision: 3.0 How to Access Environment Variables in an MS-DOS Batch FileThis article was previously published under Q121170 SUMMARY
The article explains how you can access environment variables within MS-DOS
batch files.
MORE INFORMATION
The following example shows how to test for the existence of an environment
variable:
IF "%VARIABLE%" == "" GOTO MODULE NOTE: The quotation marks are necessary only when a variable is used in a logical IF statement. The following example illustrates the use of the PATH environment variable within a batch file: IF "%PATH%" == "" GOTO NOPATH :YESPATH @ECHO The PATH environment variable was detected. PATH=C:\DOS;%PATH% GOTO END :NOPATH @ECHO The PATH environment variable was NOT detected. PATH=C:\DOS; GOTO END :END If a path is detected and control is passed to the YESPATH section, C:\DOS is added to the existing path by using the %PATH% variable. | Article Translations
|
Back to the top
