does %* in batch file mean all command line arguments?

41

9

does %* in batch file mean all command line arguments?

Matt

Posted 2010-06-07T21:41:11.690

Reputation: 5 109

Answers

53

Yes. According to the official Microsoft documentation:

The %* batch parameter is a wildcard reference to all the arguments, not including %0, that are passed to the batch file.

Matt Solnit

Posted 2010-06-07T21:41:11.690

Reputation: 1 150

4

@kokbira or you can use shift to access the rest

– TWiStErRob – 2014-11-10T13:38:07.963

@TWiStErRob - I'm sure you know it but to be clear... even with %* you need to use shift to access parameters beyond %9. The advantage of using %* is you can pass the entire ORIGINAL parameter list (including parameters that have been "shifted out") to an external batch or other program, or with a call :label %*, even if you don't know how many parameters are in the list (or if it's more than 9).

– Kevin Fegan – 2020-02-16T22:44:48.997

5note: if you have 30 words separated with spaces as argument, you can only take the 9 first words with %i, with i from 1 to 9, but with %* you can take all the 30 words – kokbira – 2011-04-25T20:38:38.703