How to set a variable equal to the contents of another variable?
15,799
As Karl ask, there could be different meanings of your question.
I try to give an answer for each possibility
@echo off
setlocal EnableDelayedExpansion
set EqS=Nope
set X=Eq
REM set Y1 to "EqS"
set Y1=%X%S
REM set Y2 to "Nope" (content of EqS)
set Y2=!%X%S!
REM set Y3 to "!EqS!"
set Y3=^^!%X%S^^!
echo %Y1%
echo %Y2%
echo %Y3%
set EqS=Something
echo(
echo Text %Y1%
echo Content %Y2%
echo Pointer %Y3%
Author by
Admin
Updated on June 09, 2022Comments
-
Admin almost 2 years
In the following (simplified example) batch file I am having difficulty correctly setting
Y
:@Echo off setlocalenabledelayed Expansion set EqS=Nope set X=Eq set Y=%X%S echo Y
How can I get the output of this script to be
Nope
instead ofEqS
?