Hardware Reference
In-Depth Information
ECHO Missing or invalid parameter
GOTO end
:valid
ECHO Index of Directories in %1
DIR %1 | FIND "<DIR>" | SORT
:end
The first line disables the echoing of subsequent commands contained within
the batch file. The second line determines whether, or not, a valid parameter
has been entered. If the parameter is invalid (or missing) the ECHO command is
used to print an error message on the screen.
Simple menus can be created with batch files. As an example, the following
batch files make a simple 'front-end' for four separate DOS applications. In
this example, three of these applications are located in the root directory whilst
the fourth, EDIT, is located in the TOOLS sub-directory:
Batch file
Contents
MENU.BAT ECHO OFF
CLS
CD \
ECHO ******** MENU ********
ECHO [1] = CONFIGURE
ECHO [2] = START PROCESS
ECHO [3] = SHUT DOWN
ECHO [4] = TEXT EDITOR
ECHO **********************
1.BAT CONFIG.EXE
2.BAT START.EXE
3.BAT CLOSE.EXE
4.BAT CD TOOLS
EDIT.EXE
In order to display the menu automatically it is necessary to include MENU.BAT
in the AUTOEXEC.BAT file. (see the example on page 135). Note that all
four of the batch files must be present in the root directory and that, when an
application terminates and returns control to DOS, it will be necessary to run
the MENU.BAT file again by simply typing MENU at the command prompt.
Using CONFIG.SYS
When DOS starts, but before the commands within the AUTOEXEC.BAT file
are executed, DOS searches the root directory of the boot disk for a file called
CONFIG.SYS. If this file exists, DOS will attempt to carry out the commands
in the file. As with any batch file, the configuration sequence can be aban-
doned by means of <CTRL-C> or <CTRL-BREAK> . CONFIG.SYS is a plain
ASCII text file with commands on separate lines. The file can be created using
any text editor or word processor operating in ASCII mode (CONFIG.SYS
can also be created using COPY CON : as described earlier for the creation of
batch files).
Search WWH ::




Custom Search