SETLOCAL EnableDelayedExpansion
FOR %%A IN (1 2 3) DO (
IF %%A EQU 1 (
SET CHOICE1=ABC
ECHO CHOICE1=%CHOICE1%
)
)
Output:
CHOICE1=
Why is CHOICE1 not getting set?
SETLOCAL EnableDelayedExpansion
FOR %%A IN (1 2 3) DO (
IF %%A EQU 1 (
SET CHOICE1=ABC
ECHO CHOICE1=%CHOICE1%
)
)
Output:
CHOICE1=
Why is CHOICE1 not getting set?
When using EnableDelayedExpansion you must also use ! around variables you want to delay expanding.
Therefore, instead of %CHOICE1% you must use !CHOICE1!.