Do someone knows how to add the action to be triggered when calling my batch file with the /? argument ? I've always used the -h to display usages, but for once I need my -h arg for something else.
EDIT : Actually I've tried by parsing attributes like this
for %%i in (%*) do ....
But the /? argument was skipped, I'll try yours solutions to see if it's different.
Btw, why when you parse %%i the /? args is skipped ?
The /?
seems to be simply skipped by the for %%i in (%*)
but it's the wildcard functionality of the for-loop, it tries to find a file that matches /?
which will fail.
You can not use ?
or *
in a "normal" for-loop, without modifying the result.
You could use the SHIFT
command to access all your parameters.
:parameterLoop
if "%~1"=="/?" call :help
if "%~1"=="-h" call :help
if "%~1"=="-o" call :other
shift
if not "%~1"=="" goto :parameterLoop
If you also want to display the selected option, you got a problem with the echo command, as this will normally show the help instead of /?
.
You can avoid this by using echo(%1
instead of echo %1
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With