What are the special characters commonly used in a batch file?

 
Batch display-suppression operator
o @ can be applied to any command as the first character on the command line in a batch program.
o It’s used to prevent an individual command from being displayed when it is executed.
 
 
Batch file label operator
o : is used to identify a location in a batch file. It is not a command but a prefix of a label.
 
o A label is a companion of the GOTO command.
i.e. GOTO <label>
:<label>
 
o A label is used to force MS-DOS to move to a specified location within the batch program.
 
o Normally, when MS-DOS runs a batch program, it executes commands in the order as they appear in the program. However, when MS-DOS comes across the GOTO command (e.g. GOTO option1), it will move to the position that is identified by :option1 within the batch program.
 
 
Batch replaceable parameter
o Consider the following commands frequently used at the DOS prompt:-
 
? copy autoexec.bat autoexec.bak
This command line creates a backup file of the autoexec.bat file.
copy is a command, autoexec.bat and autoexec.bak are parameters. These are required parameters. You must state both of them to make the command work.
 
 
? dir /w
This command line displays a directory entries of the current directory in wide screen format. dir is a command, /w is a parameter. It is an optional parameter for qualifying the output of the dir command.
 
o Similarly, we can make use of parameters to help us achieve the same capability in executing a batch program. This way, we can execute the same batch program with different data at different time. They are called replaceable parameters.
 
o %n and %%n are the special characters which represent the parameter in a batch program, where n is a single digit, from 1 through 9.
 
o The replaceable parameters are positional. The digit, n, of the special characters represents the position of the parameter we type with the batch command.
 
For example:
 
 
.  
Scroll to Top