I want to pass optional parameters to the script like that:
mybatfile.bat firstParameter -r 000 -m "Some message here"
I've got solution from different question, but I have problem with -m "Some message here"
SET firstParameter=%1
SET message=""
SET roomNumber=""
SHIFT
:loop
IF NOT "%1"=="" (
IF "%1"=="-r" (
SET roomNumber=%2
)
IF "%1"=="-m" (
set message=%~2
)
SHIFT
GOTO :loop
)
%~2 only gets first part of the word because it see every word as another parameter. I also find out I could use small hack inside if, like that
for %%x in (%*) do (
echo "%%~x"
)
And here take first "%%~x" after "-m" appear. But how to do that using script?