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
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%