Search code examples
batch-filecall

How can I make something like "abc /help" work in batch?


I have a file called abc.bat. I want it to do this code when on the command line, and in the same directory of abc.bat, I type in abc /help:

echo 2

And when it's just abc.bat or abc I type in there:

echo 96

How do I do this, so I can get a better understanding of batch?


Solution

  • You simply check the argument against /HELP

    Like

    @echo off
    if "%1"=="/help" goto :help
    
    echo 96
    exit /b
    
    :help
    echo This is the help
    exit /b