In the following example, I want to call a child batch file from a parent batch file and pass all of the remaining parameters to the child.
C:\> parent.cmd child1 foo bar C:\> parent.cmd child2 baz zoop C:\> parent.cmd child3 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
Inside parent.cmd, I need to strip %1 off the list of parameters and only pass the remaining parameters to the child script.
set CMD=%1 %CMD% <WHAT DO I PUT HERE>
I’ve investigated using SHIFT with %*, but that doesn’t work. While SHIFT will move the positional parameters down by 1, %* still refers to the original parameters.
Anyone have any ideas? Should I just give up and install Linux?
%*will always expand to all original parameters, sadly. But you can use the following snippet of code to build a variable containing all but the first parameter:I think it can be done shorter, though … I don’t write these sort of things very often 🙂
Should work, though.