Name

if

Synopsis

A conditional command. In all cases, including the not keyword, it inverts the logical expression.

if [not] errorlevel n command

Execute command if the value of the ERRORLEVEL variable is /isn’t greater than or equal to n.

if [not] defined variable command

Execute command if the specified variable is /isn’t defined.

if [not] exist file command

Execute command if the specified file does/doesn’t exist.

if [not] [/I] string1 op string2 command

Execute command if the specified string comparison expression is true/false. The available operators are:

== | EQU

Equal.

NEQ

Not equal.

LSS

Less than.

LEQ

Less than or equal.

GTR

Greater than.

GEQ

Greater than or equal.

All operators are case-sensitive. /I says to perform a case-insensitive comparison.

Get Windows 2000 Commands Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.