You can use a little trick, which, unfortunately, is not documented anywhere:
call echo %%%1%%
Then you can use the delayed extension:
setlocal enabledelayedexpansion echo !%1!
The delayed extension helps here mainly because it uses other delimiters for the variable and evaluates them immediately before running the command, while normally the evaluation may encounter a normal parameter extension.
Another way to convince this would be with a subroutine:
call :meh "echo %%%1%%" ... :meh %~1 goto :eof
All examples, including another answer, have one thing in common: they all force cmd to evaluate variables / parameters twice. This will not work otherwise, since the first estimate should produce %VariableName% , and the second will expand the contents of the variable.
You can also find my SVN code.
source share