How can I add an additional option to calling changeName.bat?
I want to configure -h
(Help) to call changeName.bat -h
How can I add an additional option to calling changeName.bat?
I want to configure -h
(Help) to call changeName.bat -h
You can directly goto
the arguments :
@echo off
If not "%~1"=="" goto:%~1 2>nul || Echo Error Invalid Argument
echo Here Your normal code without argument
exit/b
:-h
echo I'm In Help
exit/b
:-t
echo I'm in Test
exit/b
This is a very robust solution :
IF
statementA simple solution for your case:
@ECHO OFF
IF NOT "%1"=="" (
IF "%1"=="-h" (
ECHO This is the help text.
GOTO end
)
)
REM Add your instructions below and delete this line
ECHO Hello!
:end
HTH ;)