Using the Windows XP CMD command-line I can expand a variable twice as follows:
set AAA=BBB
set BBB=CCC
for /F "usebackq tokens=*" %i in (`echo %%AAA%%`) do echo %i
will echo CCC. I.e. AAA has been expanded to the string BBB, and then the variable BBB has been expanded to CCC.
This doesn't work from inside a batch script (i.e. a .cmd file). Changing the %%AAA%% to either %%%AAA%%% or %%%%AAA%%%% doesn't work either.
Any idea how i can achieve this from within a script, namely to take expand the variable AAA to the string CCC?
Late Edit
The answers posted work for my reduced example however the non-tortuous answer doesn't work for the real case. Here's an extended example (which doesn't work), which illustrates what I was actually trying to do:
setlocal enabledelayedexpansion
set LIST=BBB CCC DDD
set BBB=111
set CCC=222
set DDD=333
for %%i in (%LIST%) do (
for /F %%a in ('echo %%%i%') do echo !%%a!
)
I would like to see
111
222
333
output.