kqtran

Pass More Than 9 Arguments to a Batch Script

·

credit

Passing fewer than 9 arguments to a batch script

REM script.cmd
IF %1.==. GOTO No1
IF %2.==. GOTO No2
... do stuff...
GOTO End1

:No1
  ECHO No param 1
GOTO End1
:No2
  ECHO No param 2
GOTO End1

:End1

Pass greater than 9 arguments to a batch script

The use case isn't really for 9 distinct arguments, but more for a scenario where you need to pass an array of objects that may total greater than 9. I would always question the requirement to do this as it's most likely due to poor design, but all tools can have valid uses.

REM script.cmd
@ECHO OFF
:Loop

IF "%1"=="" GOTO Continue
   echo %1%
SHIFT
GOTO Loop

:Continue

Syntax

script.cmd parameter1 parameter2 parameter3 parameter4 parameter5