batch-file – 在IF语句WinXP Batch Script中使用OR

前端之家收集整理的这篇文章主要介绍了batch-file – 在IF语句WinXP Batch Script中使用OR前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
有没有办法通过IF语句传递OR?

如:

SET var=two
IF "%var%"=="one" OR "two" OR "three" ECHO The number is between zero and four.
没有.
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

如果您需要更有条理的方法

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
)
原文链接:https://www.f2er.com/windows/364676.html

猜你在找的Windows相关文章