Hardware Reference
In-Depth Information
Using batch files
Batch files provide a means of avoiding the tedium of repeating a sequence
of operating system commands many times over. Batch files are nothing more
than straightforward ASCII text files which contain the commands which are
to be executed when the name of the batch is entered. Execution of a batch file
is automatic; the commands are executed just as if they had been types in at the
keyboard. Batch files may also contain the names of executable program files
(i.e. those with a COM or EXE extension), in which case the specified program
is executed and, provided the program makes a conventional exit to DOS upon
termination, execution of the batch file will resume upon termination.
Batch file commands
DOS provides a number of commands which are specifically intended for
inclusion within batch files.
Command
Function
The ECHO command may be used to control screen output during
execution of a batch file. ECHO may be followed by ON or OFF ,
or by a text string which will be displayed when the command
line is executed.
Examples:
ECHO OFF
disables the echoing (to the screen) of commands contained
within the batch file.
ECHO ON
re-enables the echoing (to the screen) of commands contained
within the batch file. (Note that there is no need to use this
command at the end of a batch file as the reinstatement of screen
echo of keyboard generated commands is automatic.)
ECHO Sorting data - please wait!
displays the message:
ECHO
Sorting data - please wait!
on the screen.
You can use @ECHO OFF to disable printing of the ECHO
command itself. You will normally want to use this command
instead of ECHO OFF .
FOR is used with IN and DO to implement a series of repeated
commands.
Examples:
FOR %A IN (IN.DOC OUT.DOC MAIN.DOC) DO COPY %A LPT1:
copies the files IN.DOC, OUT.DOC, and MAIN.DOC in the
current directory to the printer.
FOR
FOR %A IN (*.DOC) DO COPY %A LPT1:
( continued )
Search WWH ::




Custom Search