Farah
Farah

Reputation: 2621

Batch : For what is percentage followed by asterisk used?

I have in a batch file this line :

Test.exe %*

I searched in google and I found this explaination :

Some DOS versions use this sign coupled with a percent sign (%*) to represent all parameters on the command line in a batch file.

But I still don't understand how to use this command...

Thank you!

Upvotes: 26

Views: 8342

Answers (2)

Farlan
Farlan

Reputation: 1900

This is used to forward the parameters you passed in to the batch file to another application.

For example if you call batch.bat param1 param2 param3 param4 and inside your batch.bat file you have Text.exe %*, it will be equivalent as calling Test.exe param1 param2 param3 param4

Upvotes: 34

GolezTrol
GolezTrol

Reputation: 116140

With that explanation, you can call an executable or other script with the exact same parameters as were passed to this script. So that allows you to easily 'wrap' an executable in a script that does some action before and/or after running the executable, while still supporting all command line parameters the executable supports.

Upvotes: 2

Related Questions