Sections: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Index | Next >
Learning objective: (3) Demonstrate the use of the replaceable parameters
In this example, note the %1 (percent one) used with the DIR command to make the batch file more flexible.
When the batch file is executed, note the "com" on the command line and the display of "com" files. It is the replaceable parameter being passed into the batch file as percent one. Replaceable parameters are separated by spaces on the command line.
DEMO.BAT com
At runtime, the command of "DEMO.BAT com" passes the value of "com" into the batch file as %1.
The extension is com
In the batch file, %1 or "com" is being used to as the extension of the DIR command.
DIR of *.com
The results of the command is to replace %1 with "com" to give the command of "c:\windows\system32\*.com". Notice the "." period is preserved.
Sections: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Index | Next >