how concatenate two variables in batch script?

前端 未结 3 1341
野的像风
野的像风 2021-02-02 15:54

I want to do something like this in batch script. Please let me know if this is the proper or possible way to do it or any other way?

set var1=A

set var2=B

set         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-02 16:37

    Enabling delayed variable expansion solves you problem, the script produces "hi":

    setlocal EnableDelayedExpansion
    
    set var1=A
    set var2=B
    
    set AB=hi
    
    set newvar=!%var1%%var2%!
    
    echo %newvar%
    

提交回复
热议问题