I wrote this one-liner to handle (only in the first argument) the help command option in batch files:
Code: Select all
@For %%? in ("" : - /)do @IF %%~??==%1 GOTO:Help
...
:Help
...
It supports whatever leading switch characters you want to allow (in the FOR command set, except "*" which triggers a wildcard replacement for files in the current directory), but as shown will, as many .EXE programs do, accept these formats:
Sadly, this falls short of your requirement that it check all parameters (it does not, only the first argument), but perhaps you may find a use since it's more forgiving in it's syntax handling your choice of leading characters.
Also, as coded, when added at the beginning of a batch file, this one-liner permits the caller to bypass it's checking by quoting the argument, enabling a method to use any existing functionality that may also check for "/?" later in the batch file at run time, e.g.: cmdhelp.bat "/?"