 <p>I struggeld for many hours on this. This is my loop to register command line vars. Example : Register.bat /param1:value1 /param2:value2</p> <p>What is does, is loop all the commandline params, and that set the variable with the proper name to the value.</p> <p>After that, you can just use set value=!param1! set value2=!param2!</p> <p>regardless the sequence the params are given. (so called named parameters). Note the !&lt;>!, instead of the %&lt;>%.</p> <pre><code>SETLOCAL ENABLEDELAYEDEXPANSION FOR %%P IN (%*) DO ( call :processParam %%P ) goto:End :processParam [%1 - param] @echo "processparam : %1" FOR /F "tokens=1,2 delims=:" %%G IN ("%1") DO ( @echo a,b %%G %%H set nameWithSlash=%%G set name=!nameWithSlash:~1! @echo n=!name! set value=%%H set !name!=!value! ) goto :eof :End </code></pre>