The batch language has a full set of Boolean logical operators such as AND, OR, XOR, but only for binary numbers. There are also no values for TRUE or FALSE.
The following table lists the available logical operators.
| Operator | Description |
|---|---|
AND |
This is the logical and operator |
OR |
This is the logical or operator |
NOT |
This is the logical not operator |
Implement AND operator to use in if conditions
Logical AND is implemented with nested conditions:
@echo off
set /A a=5
set /A b=10
if %a% geq 5 (
if %b% leq 10 (
echo "True Result"
)
)"True Result"Implement OR operator to use in if conditions
Logical OR is implemented with a separate variable:
@echo off
set /A a=5
set /A b=10
set result=false
if %a% == 1 set result=true
if %b% == 1 set result=true
if "%result%" == "true" (
echo "True result"
)"True Result"