批处理脚本 - 关系运算符

关系运算符允许对对象进行比较。 以下是可用的关系运算符。

以下代码片段显示了如何使用各种运算符。

示例

@echo off 
SET /A a = 5 
SET /A b = 10 
if %a% EQU %b% echo A is equal to than B 
if %a% NEQ %b% echo A is not equal to than B 
if %a% LSS %b% echo A is less than B 
if %a% LEQ %b% echo A is less than or equal B
if %a% GTR %b% echo A is greater than B 
if %a% GEQ %b% echo A is greater than or equal to B

输出

上述命令会产生以下输出。

A is not equal to than B
A is less than B
A is less than or equal B

❮ batch_script_operators.html