变量延迟
@echo off& setlocal enabledelayedexpansion
. . . .
do (set m=%%i
echo !m!)
或者m赋值后结束for循环,
之后的代码放饭括号外执行,这样不必开延迟
@echo off
setlocal enabledelayedexpansion
for /F "tokens=1-3" %%i in ('reg query "HKLM\Software\Microsoft\MediaPlayer" /v "IEInstall"') do (
if "%%i"=="IEInstall" (
echo "%%i %%j %%k"
set m=%%i
echo "!m!"
echo "!m:~0,1!"
set v=!m:~0,1!
echo "!v!"
)
)