Many programs are able to handle input parameters, which one can specify when launching the program from the command line. This usually makes the program more generic and a better tool to work with (Ex. giving “a:” as parameter):

Format a:

When starting a batch file, then one can also specify input parameters. The parameters can be accessed by the batch file like environment variables, and have the values %1 to %9.

To check if a parameter is given:

IF “%1”!=”” ECHO Got %1

More Info MS KB71247

Note there also exists the input parameter %0, which is actually the batch-filename it self.

Note one can also use the SHIFT command incase the input parameter doesn’t have to be in a certain order. SHIFT moves the parameter one to the left so %1 disappears, %2 becomes %1, %3 becomes %2 and etc. This behavior can be useful when having a batch file which receives an undefined order or amount of parameters.

:PARSELOOP
IF “%1”==”” GOTO ENDPARSE
IF “%1”==”DEBUG” SET BUILD=DEBUG
IF “%1”==”RELEASE” SET BUILD=RELEASE
SHIFT
GOTO PARSELOOP
:ENDPARSE