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
)