Reputation: 81
Suppose I have env variables in windows:
IA=C:\a
IB=C:\b
now I write a batch script:(named s.bat)
@echo off
set var=%1
echo %var%
When I run s.bat IA
,the result is IA
, but I actually want the result to be C:\a
. How can I achieve this requirement?
Upvotes: 3
Views: 55
Reputation: 82307
You can use delayed expansion or the call trick.
@echo off
setlocal EnableDelayedExpansion
set "varname=%1"
echo %varname%
echo !%varname%! - This works
call echo %%varname%% - This too
Upvotes: 5