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

Windows 当使用命令行的引用参数时,如何进行条件检查(if命令)?,windows,command-line,batch-file,if-statement,Windows,Command Line,Batch File,If Statement,在批处理文件中,我有以下脚本: set myVar=/someLabel:"%1" 我想为上面的脚本编写if命令,其含义与下面相同 if <%1 not null> { myVar=/someLabel:"%1" } else { myVar="" } if{ myVar=/someLabel:“%1” } 其他的 { myVar=“” } 我该怎么做 [编辑] 用户hfs的答案对我很有用 and命令的完整详细信息由用户Dave Anderson列出。您需要确保已启

在批处理文件中,我有以下脚本:

set myVar=/someLabel:"%1"
我想为上面的脚本编写
if
命令,其含义与下面相同

if <%1 not null> {
  myVar=/someLabel:"%1"
} 
else
{
  myVar=""
}
if{
myVar=/someLabel:“%1”
} 
其他的
{
myVar=“”
}
我该怎么做

[编辑] 用户
hfs
的答案对我很有用


and命令的完整详细信息由用户Dave Anderson列出。您需要确保已启用延迟变量扩展,或者无论您的IF语句如何,始终用传递到批处理文件的内容替换%1

set myVar=
if not "%1" == "" set myVar=/someLabel:%1
下面是对命令和命令的极好解释