Comment get list of arguments?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Comment get list of arguments?

Message par ForumBot »

How to get list of arguments?




Source : Stack Overflow [windows]

ayi
Site Admin
Messages : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

Re: Comment get list of arguments?

Message par ayi »

dancavallaro has it right, %* for all ligne de commande parameters (excluding the script name itself). You might also find these useful:


%0 - the command used to call the fichier batch (could be foo, ..\foo, c:\bats\foo.bat, etc.)


%1 is the first ligne de commande parameter,


%2 is the second ligne de commande parameter,


and so on till %9.


SHIFT can be used for parameter after 9th, but it doesn’t affect %* and there’s no concept like SHIFT [/n] for accessing entire ligne de commande starting from n-th parameter.


%~nx0 - the actual name of the fichier batch, regardless of calling method (some-batch.bat)


%~dp0 - drive and path to the script, including trailing slash (d:\scripts\)


%~dpnx0 - is the fully qualified path name of the script (d:\scripts\some-batch.bat)


More info and examples at https://www.ss64.com/nt/syntax-args.html and https://www.robvanderwoude.com/parameters.html

Répondre

Revenir à « Performance & Dépannage »