Setting the value of environment variable BOOBOO inside the if block does not appear to set it. However, it is set after the if block ends. Why does it not have a value inside the if block?
Running on Microsoft Windows XP [Version 5.1.2600] SP3
echo BOOBOO is +++%BOOBOO%+++
echo step 1
setlocal enableextensions
IF "%BOOBOO%" == "" (
echo step 2
SET BOOBOO=xyz
echo step 3
echo BOOBOO has been set to %BOOBOO%
echo BOOBOO part is %BOOBOO:~0,2%
echo step 4
)
echo step 8
echo BOOBOO ends up as %BOOBOO%
echo step 9
EXIT /B 0
===
M:> t
BOOBOO is ++++++
step 1
step 2
step 3
BOOBOO has been set to
BOOBOO part is ~0,2
step 4
step 8
BOOBOO ends up as xyz
step 9