Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch : For what is percentage followed by asterisk used?

Tags:

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!

like image 484
Farah Avatar asked Nov 11 '13 18:11

Farah


People also ask

Why is %% used in batch file?

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.

What does * * mean in CMD?

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.

What does %I mean in a batch command?

%%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?

What is %% K in batch file?

So %%k refers to the value of the 3rd token, which is what is returned.


1 Answers

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

like image 139
Farlan Avatar answered Oct 07 '22 01:10

Farlan