CMD - 如何使用变量名中的其他变量设置变量

CMD - how does one set a variable using other variables in the variable name

我想设置一个在其名称中使用另一个变量的变量。我想做类似的事情:

set a=2
set b=0
set s%a%%b%=Yee

显然,这行不通,但我希望能够通过以下方式调用变量:

echo %s20%

所以它会回显 Yee。这可能是你做不到的事情,但它会让设置很多变量变得容易得多。

@echo off
set a=2
set b=0
set s%a%%b%=Yee


call echo %%s%a%%b%%%
:: OR ::
setlocal enableDelayedExpansion

echo !s%a%%b%!

endlocal

最好使用延迟扩展的方式,因为调用会影响性能。