I was a bit late for the party, but another way to deal with this condition is to continue the process on the street, if , like this
set var1=true if "%var1%"=="true" ( set var2=myvalue ) echo %var2%
Or / and use goto syntax
set var1=true if "%var1%"=="true" ( set var2=myvalue goto line10 ) else ( goto line20 ) . . . . . :line10 echo %var2% . . . . . :line20
This way, the extension happens "on time" and you do not need setlocal EnableDelayedExpansion . As a result, if you rethink the design of your script, you can do it like this
TS Mar 27 '18 at 21:14 2018-03-27 21:14
source share