在如何在批处理文件中传递命令行参数的基础上,如果我不想指定具体参数,怎么获取其他参数?我不想使用SHIFT,因为我不知道可能会有多少个参数,如果可能的话,我想避免计数。
例如,给定这个批处理文件:
@echo off
set par1=%1
set par2=%2
set par3=%3
set therest=%???
echo the script is %0
echo Parameter 1 is %par1%
echo Parameter 2 is %par2%
echo Parameter 3 is %par3%
echo and the rest are %therest%
执行mybatch opt1 opt2 opt3 opt4 opt5 ...opt20
将产生以下结果:
the script is mybatch
Parameter 1 is opt1
Parameter 2 is opt2
Parameter 3 is opt3
and the rest are opt4 opt5 ...opt20
我知道 %*
可以获取所有参数,但我不想要前三个(例如)。