Pass an argument while calling Windows batch file

Chris 19 Rep.


I have created a batch file which performs certain task on conditions. But the conditions are being checked based on the argument we supply in a batch file. I am not sure how to pass arguments for Windows batch file and use them in conditions?



Scott selected answer

Best answer

Scott 33 Rep.

Passing an argument in a batch file is easy. For example, if your batch file name is myfile.bat and you want to pass some argument, you can execute following command:

myfile myargument

The value myargument will be stored in %1 and you can store in variable as follow:

set arg1=%1

Scott selected as best answer


Login to see your profile links
Bloom Email Optin Plugin