Tag Archives: operator

Logical operators AND, OR in batch

There is no method to combine operators in windows BATCH command shell.
But we can easily emulate it!

For AND operator use next snippet:

if %var% GEQ 1 (
    if %var% LEQ 10 (
        // do...

For OR operator we have to use additional variable:

set result=false

if %var% LEQ 0 set result=true
if %var% GEQ 10 set result=true

if "%result%" EQU "true" (
   // do...

Thanx to http://stackoverflow.com/a/2143396