Conditionally controls the interpretation of statement based on the value of condition.
Condition |
Value |
---|---|
EXIST filename |
True if filename exists; false otherwise. Example: IF EXIST temp DELETE temp Deletes the file temp if it exists. |
ERRORLEVEL number |
True if current error level is equal to number. Example: IF ERRORLEVEL 0 GOTO label |
"string1" == "string2" |
True if the strings match. Strings can contain a variable, such as %SNUSER%, which is expanded before testing for a match. Strings can also contain a literal % by having two %% in a literal--the first % escapes the second %. Exampl:e IF "%SNUSER%" == "root" EXIT If the user is root, then exit. |