What does %* mean in a batch file?
One important point not listed in any of the previous answers: %*
expands to all parameters from the command line, even after a SHIFT
operation.
Normally a SHIFT
will move parameter %2
to %1
, %3
to %2
, etc., and %1
is no longer available. But %*
ignores any SHIFT
, so the complete parameter list is always available. This can be both a blessing and a curse.
It means "all the parameters in the command line".
For example, it's useful when you want to forward the command line from your batch file to another program:
REM mybatchfile.cmd
echo You called this with arguments: %*
echo I will now forward these to the DIR command.
dir %*