SoFunction
Updated on 2025-04-08

bat passes more than 10 parameters

The parameters that can be referenced in the batch file are %0~%9. %0 refers to the batch file itself, which can also be said to be an external command; %1~%9 is a batch parameter, also known as a formal parameter; and if the actual parameters that replace the formal parameter exceed the value (9) specified in the batch file and you want to apply these actual parameters in the batch file, the shift command can help you implement it!

Shift command: Change the location of replaceable parameters in batch files
C code
shift [/n] 
shift [/n]n is an integer; [/n] is an optional parameter. When n is assigned a certain value, it means that the command starts to shift from the nth parameter; when n is assigned a value of 0, 1 or shift without any command options, it means that the replacement parameters in the batch file are shifted left by one position, and the subsequent replacement parameters are filled one after another until the replaceable parameters are empty.


eg: Create batch file d:\;C code

Copy the codeThe code is as follows:

@echo off  
cls  
echo   %1 %2 %3 %4 %5 %6 %7 %8 %9  
shift /0  
echo   %1 %2 %3 %4 %5 %6 %7 %8 %9  
shift /1  
echo   %1 %2 %3 %4 %5 %6 %7 %8 %9  
shift /2  
echo   %1 %2 %3 %4 %5 %6 %7 %8 %9  
shift /3  
echo   %1 %2 %3 %4 %5 %6 %7 %8 %9  
shift /4  
echo   %1 %2 %3 %4 %5 %6 %7 %8 %9  
shift /5  
echo   %1 %2 %3 %4 %5 %6 %7 %8 %9  
shift /6  
echo   %1 %2 %3 %4 %5 %6 %7 %8 %9  
shift /7  
echo   %1 %2 %3 %4 %5 %6 %7 %8 %9  
shift /8  
echo   %1 %2 %3 %4 %5 %6 %7 %8 %9  
pause 1>nul 
@echo offclsecho %1 %2 %3 %4 %5 %6 %7 %8 %9shift /0echo %1 %2 %3 %4 %5 %6 %7 %8 %9shift /1echo %1 %2 %3 %4 %5 %6 %7 %8 %9shift /2echo %1 %2 %3 %4 %5 %6 %7 %8 %9shift /3echo %1 %2 %3 %4 %5 %6 %7 %8 %9shift /4echo %1 %2 %3 %4 %5 %6 %7 %8 %9shift /5echo %1 %2 %3 %4 %5 %6 %7 %8 %9shift /6echo %1 %2 %3 %4 %5 %6 %7 %8 %9shift /7echo %1 %2 %3 %4 %5 %6 %7 %8 %9shift /8echo %1 %2 %3 %4 %5 %6 %7 %8 %9pause 1>nul

Then enter test 1 2 3 4 ......17 at the command prompt d:\ to display the execution result, and you will know the rules! C code
D:\>test 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  

1 2 3 4 5 6 7 8 9  
2 3 4 5 6 7 8 9 10  
3 4 5 6 7 8 9 10 11  
3 5 6 7 8 9 10 11 12  
3 5 7 8 9 10 11 12 13  
3 5 7 9 10 11 12 13 14  
3 5 7 9 11 12 13 14 15  
3 5 7 9 11 13 14 15 16  
3 5 7 9 11 13 15 16 17  
3 5 7 9 11 13 15 17