Supports conditional logic in scripts.
if [not] errorlevel number command [else expression] if [not] string1==string2 command [else expression] if [not] exist filename command [else expression] if [/i] string1 compare-op string2 command [else expression] if cmdextversion number command [else expression] if defined variable command [else expression]
Parameters | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||
Parameter | Purpose | ||||||||||||
| |||||||||||||
[not] | Reverses the test condition. | ||||||||||||
errorlevel number | Sets a true condition if the previous program returned an exit code equal to or greater than number. | ||||||||||||
command | Identifies a command that the shell is to execute if the preceding condition is satisfied. | ||||||||||||
string1==string2 | Specifies a true condition when string1 and string2 are the same. | ||||||||||||
exist filename | Specifies a true condition when a filename exists. | ||||||||||||
compare-op | Can be any of the following operators:
| ||||||||||||
[/i] | Forces case-insensitive string comparisons. | ||||||||||||
cmdextversion number | Compares the internal version number associated with CMD.EXE to the specified number. | ||||||||||||
defined variable | Returns true if the environment variable is defined. | ||||||||||||
[else expression] | Specifies the command and any parameters that need to be passed to the command. |