It is very easy to pass the commandline arguments to any batch script. Mainly the parameters are available at the variables %0, %1, %2 ... etc. The %0 holds the name of the batch script, and others are the parameters.
Here is sample script named test.bat:
Running the script using following command with no second argument available:
Output:
Running the script using the following command:
Output:
Here is sample script named test.bat:
echo off
echo %0
echo %2
echo %1
Running the script using following command with no second argument available:
D:\work>test.bat "commandline param"
Output:
test.bat
ECHO is off.
"commandline param"
Running the script using the following command:
D:\work>test.bat "commandline param" hello
Output:
test.bat
hello
"commandline param"
Comments