JSI Tip 6792. How many parameters can I pass to batch file?
Jerold Schulman
June 2, 2003
2 Min Read
There is no practical limit to the number of parameters you can pass to a batch file, but you can only address parameter 0 (%0 - The batch file name) through parameter 9 (%9).
To circumvent this behavior, you can use the SHIFT command, as in the following example:
test a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9
where test.bat might contain:
@echo off
@echo %0
:again
if {%1}=={} goto :EOF
@echo %1 %2 %3 %4 %5 %6 %7 %8 %9
shift
goto again
With the above parameters, test.bat would display:
testa b c d e f g h ib c d e f g h i jc d e f g h i j kd e f g h i j k le f g h i j k l mf g h i j k l m ng h i j k l m n oh i j k l m n o pi j k l m n o p qj k l m n o p q rk l m n o p q r sl m n o p q r s tm n o p q r s t un o p q r s t u vo p q r s t u v wp q r s t u v w xq r s t u v w x yr s t u v w x y zs t u v w x y z 0t u v w x y z 0 1u v w x y z 0 1 2v w x y z 0 1 2 3w x y z 0 1 2 3 4x y z 0 1 2 3 4 5y z 0 1 2 3 4 5 6z 0 1 2 3 4 5 6 70 1 2 3 4 5 6 7 81 2 3 4 5 6 7 8 92 3 4 5 6 7 8 93 4 5 6 7 8 94 5 6 7 8 95 6 7 8 96 7 8 97 8 98 99
About the Author
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
You May Also Like