Mec*_*ash 9 windows conditional cmd if-statement batch-file
有没有办法通过IF语句传递OR?
如:
SET var=two
IF "%var%"=="one" OR "two" OR "three" ECHO The number is between zero and four.
Run Code Online (Sandbox Code Playgroud)
Joe*_*oey 14
没有.
if "%var%"=="one" goto foo
if "%var%"=="two" goto foo
if "%var%"=="three" goto foo
goto afterfoo
:foo
echo The number is between one and three (technically incorrect, since it includes the end points and thus is not between).
:afterfoo
Run Code Online (Sandbox Code Playgroud)
如果您需要更有条理的方法:
if "%var%"=="one" set OneToThree=1
if "%var%"=="two" set OneToThree=1
if "%var%"=="three" set OneToThree=1
if defined OneToThree (
echo Foo
) else (
rem something
)
Run Code Online (Sandbox Code Playgroud)