@echo off
set VAR=after
if "%VAR%" == "before" (
set VAR=after
if "!VAR!" == "after" @echo If you see this, it worked
)
@echo off
set VAR=before
if "%VAR%" == "before" (
set VAR=after
if "!VAR!" == "after" @echo If you see this, it worked
)
按理说下面一个 应该显示: If you see this, it worked
但是我这里两个什么都不显示。
set LIST=
for %i in (*) do set LIST=!LIST! %i
echo %LIST%
应该返回全部文件啊
我这却返回 !LIST! q.bat ::q.bat 是最后一个文件
set LIST=
for %i in (*) do set LIST=%LIST% %i
echo %LIST%
返回q.bat作者: lxmxn 时间: 2007-11-26 14:15 脚本前面加上“Setlocal EnableDelayedExpansion”这样一句,作用是开启批处理脚本变量延迟扩展。