Adding /? switch to parties?

Does anyone know how to add an action to run when calling my batch file with / argument ? ? I always used -h to display usage, but this time I need my -h arg for something else.

EDIT: Actually, I tried to parse attributes like this

for %%i in (%*) do ....

But the argument /? was skipped, I will try your solutions to see if it is different.

Btw, why did you omit the / arguments when parsing %% i ? ?

+5
source share
3 answers

/? for %%i in (%*), for-loop, , /?, .

? * "" , .

SHIFT .

:parameterLoop
if "%~1"=="/?" call :help
if "%~1"=="-h" call :help
if "%~1"=="-o" call :other
shift
if not "%~1"=="" goto :parameterLoop

, echo, /?.

, echo(%1 echo %1.

+6

(% 1,% 2 ..) /? string true, ECHO. ,

@ECHO OFF
IF "%1"=="/?" (
    ECHO "Help Line 1"
    ECHO "Help Line 2"
) ELSE (
    ECHO "Do Your Action"
)
+3

:

@echo off
if "%1"=="/?" goto print_help
goto normal_start

:print_help
echo Here is your help
goto end

:normal_start
echo I'm working

:end
+1
source

All Articles