How to set a variable equal to the contents of another variable?

In the following (simplified example) batch file, I am having difficulty configuring 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 as Nope instead of EqS ?

+4
source share
1 answer

As Carl asks, there may be different meanings of your question.
I try to give an answer for every opportunity.

 @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% 
+5
source

Source: https://habr.com/ru/post/1384410/


All Articles