Windows - Command Prompt %

In Windows batch file, % can be use to get command line parameters values from input.

If you have a call a batch file with abc.exe hello world

echo %2 will return world.

There is a limitation of input parameter and the limitation is 9. That is, it can handle %0 to %9 parameters

What if you have something like this your batch file

echo hello%02world

If you call the program with abc.exe hello world, it will print

helloworldworld.

The batch program will replace %02 with the third input parameters.

You can escape % with another % parameter

So, if you batch file has


echo hello%%02world

Calling abc.exe hello world will print

hello%02world

Comments

Popular Posts