I’m trying to handle an input argument when I do call script.bat argument
If argument is missing, the receiving script.bat will pop a prompt to ask user to assign value. But right now even if I do script.bat number, the prompt shows up anyway…not sure why.
Code:
:Loop
IF "%1"=="" GOTO Prompt
set VAR=%1
SHIFT
GOTO Loop
:Prompt
set /p VAR="Check which value? "
GOTO Continue
:Continue
You need to skip the
:Promptif the argument was supplied correctly:Actually, you can now remove the
SHIFTandGOTO Loop; as @dbenham posted in the comment below, it’s unreachable code. This also eliminates the:Loopitself, as it is never used. This reduces it to: