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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)