SHIFT does not affect %*

April 22, 2006 – 12:22 | microsoft

In a Windows batch file, SHIFT moves all (or part of if you give an optional parameter) the command line prameters to the left for one. So, after a SHIFT command, %0 has %1 used to have, %1 has %2 used to have, and so on. But the %* variable, which holds the entire set of parameters, is not affected at all. So if you have foo.cmd calling bar.cmd, and in foo.cmd, after it has processed the first several parameters, and shifted them off the parameter list, in order to pass the rest of the parameters to bar.cmd, foo.cmd must enumerate %1 to %9 on the line calling bar.cmd, rather than simply using %*, which would pass the entire line of original parameters to bar.cmd.

Trackback from your site, or follow the comments in RSS.

Post a Comment