I need to be able to pass parameters to a windows batch file BY NAME (and NOT by order). My purpose here is to give end user the flexibility to pass parameters in any order, and
OP's CMD
args are all in the form "[VarName]=[Something]"
FOR %%_ IN (%*) DO SET "%~_"
or in nicer looking code
FOR %%_ IN (%*) DO SET "%~_"
That said here is a more complete script example where you could just put all of your script within the :Main
function
@( Setlocal
ECHO OFF
FOR %%_ IN (%*) DO SET "%~_"
)
CALL :Main
( ENDLOCAL
EXIT /B )
:Main
REM Your code goes here.
REM Your code goes here.
REM Your code goes here.
REM Your code goes here.
GOTO :EOF