windows - 使用命令行的引用参数时如何进行条件检查(if 命令)?

标签 windows command-line batch-file if-statement

在我的批处理文件中我有脚本:

set myVar=/someLabel:"%1"

我想为上面的脚本编写 if 命令,其含义与下面相同。

if <%1 not null> {
  myVar=/someLabel:"%1"
} 
else
{
  myVar=""
}

我该怎么做?

[编辑]

用户 hfs 的回答对我有用。

if 的完整详细信息和 set命令由用户 Dave Anderson 列出。

最佳答案

set myVar=
if not "%1" == "" set myVar=/someLabel:%1

关于windows - 使用命令行的引用参数时如何进行条件检查(if 命令)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3930918/

相关文章:

MYSQL 终端 Mac 命令不工作 'mysql'

windows - 如何创建可视化 SVN 存储库并获取该 URL

windows - 批处理文件 : pass parameter with white spaces to function

windows - Windows 批处理脚本起始行中的双引号

c++ - 显示图像 Sprite 中的特定图像

python - 使用 Python 读取元数据

linux - 在下标中使用 exec 重定向标准输出

node.js - 为什么我在使用 npm install -g package 时得到 Unexpected token '\u0000'

windows - 固定的 Windows Git Bash 任务栏图标不尊重 git-bash.exe 快捷方式启动目录

string - bat文件替换文本文件中的字符串