How to get the rest of arguments in windows batch file?

batch-file, windows

Solution

@ECHO OFF
SETLOCAL
SET allargs=%*
IF NOT DEFINED allargs echo no args provided&GOTO :EOF 
SET arg1=%1
CALL SET someargs=%%allargs:*%1=%%
ECHO allargs  %allargs%
ECHO arg1     %arg1%
ECHO someargs %someargs%

This will leave `SOMEARGS` with at least one leading separator (if it is set)

Problem

I know I can get first argument with %0, second with %1, and so on.. And I can also get all arguments with %*. Can I get all arguments from the second arguments? For example, if I run ``` foo.bat bar1 bar2 bar3 bar4 ``` How can I get only `bar2 bar3 bar4`?

Original source