Batch-file “and if” statement

守給你的承諾、 提交于 2020-01-06 11:36:36

问题


I have no idea at all how to make an "and if" statement for my batch file, and I hope I could get some help in here.

The line I'm trying to make:

if %a%==X/O and if %b%==X/O goto done

回答1:


Batch doesn't have support for ands or ors in if logic. You can simulate an and by nesting your conditions.

if %a%==X/O (
    if %b%==X/O (
        goto done
    )
)

Similarly, you can simulate an or by having two separate checks.

if %a%==X/O goto done
if %b%==X/O goto done


来源:https://stackoverflow.com/questions/33708207/batch-file-and-if-statement

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!