The idea is to loop through the list of parameters and if -l is found then call another section that then extracts the next parameter.
The SHIFT, removes the first parameter from the list of available parameters. eg:
If you ran: sampl.exe -s ssss -m mmmm -l path -k kkkk -d dddd
The available parameters would be = -s ssss -m mmmm -l path -k kkkk -d dddd\
If in the script you executed SHIFT, then the available parameters would be = ssss -m mmmm -l path -k kkkk -d dddd
See the code example below:
@ECHO OFF
SET path=
SET mmm=
SET sss=
SET ddd=
REM Loop through passed parameters
:LOOP
IF [%1]==[] GOTO LOOP_END
IF [%1]==[-s] @CALL :PROCESS_S %2
IF [%1]==[-m] @CALL :PROCESS_M %2
IF [%1]==[-l] @CALL :PROCESS_L %2
IF [%1]==[-d] @CALL :PROCESS_D %2
SHIFT
GOTO LOOP
:LOOP_END
REM call your actual end result here.. Once the batch file gets here, the variable path would have been set if there was a -l <my path> passed, otherwise it would be empty
cd %path%
runmyprogram.exe %sss% %mmm% %ddd%
GOTO:EOF
REM Define your methods down here.
:PROCESS_S
IF [%1]==[] GOTO:EOF
SET sss=%1
SHIFT
GOTO:EOF
:PROCESS_M
IF [%1]==[] GOTO:EOF
SET mmm=%1
SHIFT
GOTO:EOF
:PROCESS_L
IF [%1]==[] GOTO:EOF
SET path=%1
SHIFT
GOTO:EOF
:PROCESS_D
IF [%1]==[] GOTO:EOF
SET ddd=%1
SHIFT
GOTO:EOF