【发布时间】:2014-07-23 14:09:35
【问题描述】:
我有以下 Windows 批处理文件:
@echo off
set MYVAR1=test
set MYVAR2=
set MYVAR3=a b c
setlocal enableDelayedExpansion
for /l %%x in (1, 1, 3) do (
if !MYVAR%%x! == "" (
echo Not defined
) else (
echo Variable is: !MYVAR%%x!
)
)
我希望它打印以下输出:
Variable is: test
Not defined
Variable is: a b c
相反,我看到以下输出:
Variable is: test
Variable is:
Variable is: a b c
这对我来说没有任何意义!如何更改批处理脚本以获得所需的输出?
【问题讨论】:
标签: windows batch-file