Search code examples
batch-filedos

How to assign var as a part of an other var in a batch file


How to assign var as a part of an other var in a batch file?

Im trying that but is not working:

@ECHO OFF
SET VAR1 = Value1
SET VAR2 = %VAR1%AndOtherThing
ECHO %VAR2%

Result: echo is off Expected result: Value1AndOtherThing

Thanks


Solution

  • @ECHO OFF
    SET VAR1= Value1
    SET VAR2= %VAR1%AndOtherThing
    ECHO %VAR2%
    

    don't put spaces in front of the equals.