windows-xp - Windows批处理文件: multiple if conditions

标签 windows-xp batch-file

有没有办法这样说

if %1 == 1 or %1 == 2

在批处理文件中?或者,如果我可以指定一组候选值,例如

if %1 in [1, 2, 3, 4, ... 20]

最佳答案

事实证明“and”很简单——只是不是您期望的语法: 这 3 个例子说明了这一点。

换句话说:If 1==1 AND 2==2 then echo "hello"

if 1==1 echo hello
hello

if 1==1 if 2==2 echo hello
hello

if 1==1 if 2==1 echo hello
(nothing was echoed)

关于windows-xp - Windows批处理文件: multiple if conditions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6060046/

相关文章:

windows - 修改for循环以在批处理脚本中不使用延迟扩展

batch-file - 批处理文件目录扩展

windows - 批处理 : How to run a program when the computer is idle and stop when it's used?

android - 创建 adb pull bash 命令

windows-xp - 如何在没有VB的情况下制作模型截图

windows - 如何更改 Windows 控制台窗口的宽度?

java - 安装 Hadoop 时出错

windows - 播放音乐后停止

Git diff 不会忽略 .gitignore 中的指定文件

c# - 制作动画任务栏应用程序