Tuesday, November 6, 2012

What are “%1” and “%2” in batch files?

It represents the first command line argument passed to the batch file.
If you run your batch file with:
myfile.bat firstArg secondArg
%1 becomes "firstArg" and %2 becomes "secondArg"
The related shift command shifts the position of arguments one to the left. Running shift once in a batch file will make "%1" value to be the second argument, "%2" becomes the third, and so on. It's useful for processing command line arguments in a loop in the batch file.

http://stackoverflow.com/questions/2309968/what-are-1-and-2-in-batch-files

No comments:

Post a Comment