set var=1 set switch=on if "%switch%"=="on" ( set var=2 echo %var% REM it prints 1 )It actually prints the original value 1. To avoid such unexpected behaviour, you need to set EnableDelayedExpansion, and using !var!:
setlocal EnableDelayedExpansion set var=1 set switch=on if "%switch%"=="on" ( set var=2 echo !var! REM it prints 2 )
No comments:
Post a Comment