Cmd - get variable in variable name

陌路散爱 提交于 2019-11-29 15:27:45
set a=1
set b=a
call echo %%%b%%%

And this will work faster:

@echo off
set a=1
set b=a
setlocal enableDelayedExpansion
echo !%b%!
endlocal

And just in case you need to do this within brackets context (e.g. if , for ...) :

@echo off
set a=1
set b=a
setlocal enableDelayedExpansion
(
 for /f %%v in ("%b%") do echo !%%~v!
)
endlocal

like for the variable x%abc%,

echo x%abc%>a.a
set /p temp=<a.a
call echo %%temp%%>a.a
set /p temp=<a.a
set temp

That's all!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!