What is %1~%9 parameters & how to use them in bat files

Could you, please, explain how to use %1 ~ %9 in bat files.
Where they are used. How to write bat files correctly?
I tried to experiment with them but to no avail.
Where should they be written, where do they take ‘parameters’ from? How to refer to them?
Examples would be of great use!

1 Like

I think this is a good explanation: What is %1, \1, and $1?

They basically take in the arguments you type when invoking the file to run.

Let’s say your file is named foo.bat and we have

echo this is %1

then in the command-line we run

foo.bat bar

the output should be something like

this is bar