Firedan1176
Firedan1176

Reputation: 681

Batch file - Custom CMD commands; /? or help display?

I know that when you type a command then pass a question mark, it will return information on the syntax, such as set /?. So how can I do this in a batch file? Such as if I have my batch file in the cmd's root directory and I call it such as "batchTest /?" that it will display a help message?

Upvotes: 0

Views: 690

Answers (3)

user17041796
user17041796

Reputation: 1

rem This is the custom command you are writing
set sh=netsh
rem coding structure
echo This is my own syntax

set /p input= EOF>

if %input%==sh goto sh

:sh
%sh%
rem I think this should work too!

Upvotes: 0

Mark Elder
Mark Elder

Reputation: 4127

You can use an if statement to check for a paramater of '/?' and print out the help information if it is found. Here is an example:

if '%1'=='/?' goto :HELP

echo Here is the Main batch file

goto :EOF

:HELP
echo Print Help Information

Upvotes: 1

MichaelS
MichaelS

Reputation: 6042

This will work:

IF "%1"=="/?" (
    ECHO help line 1
    ECHO help line 2
    ECHO help line 3
)

Upvotes: 1

Related Questions