0
可能重复使用OR:
Logical operators (“and”, “or”) in DOS batch在和IF语句
我可以使用或在IF语句?像这样的:
if %str% equ 1 **OR** %str% equ 2 echo %str%
可能重复使用OR:
Logical operators (“and”, “or”) in DOS batch在和IF语句
我可以使用或在IF语句?像这样的:
if %str% equ 1 **OR** %str% equ 2 echo %str%
不,你不能。你可以用一个goto
做到这一点:
if %str% equ 1 goto dosomething
if %str% equ 2 goto dosomething
goto aftersomething
:dosomething
rem do something
:aftersomething
或用一个临时变量:
set var=
if %str% equ 1 set var=1
if %str% equ 2 set var=1
if defined var (
rem do something
)