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!
Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.
In this case, we used the * wildcard to mean "all files in the current directory". This command prints the line containing the given string, and if there's more than one file in the list, the name of the file where it was found.
%%i is simply the loop variable. This is explained in the documentation for the for command, which you can get by typing for /? at the command prompt. The fact that a double percent sign is used in a batch file is discussed in these links: What is the difference between % and %% in a cmd file?
So %%k refers to the value of the 3rd token, which is what is returned.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With