How to identify user input help (/?) in batch file

74 views Asked by At

Usually in most of the batch command, it uses /? to get the description or hel of the particular command. So is there a way to identify user is asking for the help by entering /? as argument (mybatchfilename /?)

I have tried IF %1==/? goto Help. but seems ? has special meaning in batch command.

Any help?

1

There are 1 answers

0
AudioBubble On

Here I show help if no switch is selected. Also the last line shows how to test for a specific parameter (/ud but you can change it to -? and /?)

If not "%1"=="" goto main

echo   Filter.bat

echo   ==========
echo     The Filter program is a vbs file for searching, replacing, extracting, and 
echo     trimming console output and text files.
echo.
echo     Filter.bat makes Filter.vbs easily usable from the command line. It 
echo     controls unicode/ansi support and debugging.
echo.
echo       Type Filter /? for more information.
echo.

cscript //nologo "C:\Users\David Candy\Desktop\Filter.vbs" menu
Goto :EOF

:Main

Rem /ud Unicode and Debug

If %1==/ud FOR /F "tokens=1*" %%i IN ("%*") DO cscript "C:\Users\David Candy\Desktop\Filter.vbs" //nologo //u //x %%j&Goto :EOF