Title: Introduction to Batch Files
1Chapter 10
- Introduction to Batch Files
2Overview
- A batch file is a text file that contains an
ordered series of commands.
3Overview
- Batch files allow the user to
- automate a process
- create more powerful
- commands
4Concepts of Batch Interactive Processing
- A batch file contains one or more commands.
5Concepts of Batch Interactive Processing
- A batch file must have the extension .BAT
6Concepts of Batch Interactive Processing
- Batch files allow the user to
- minimize keystrokes
- minimize the
- possibility of errors
-
7Concepts of Batch Interactive Processing
- In interactive processing (real-time mode)
- the user directly
- interacts with
- computer
- info. is processed
- without delay
8How Batch Files Work
- The difference between Data and Program files is
determined by their file extensions.
9How Batch Files Work
- Priority rules are followed when the OS looks for
a file to load and execute.
10How Batch Files Work
- The .BAT extension is the last file extension the
OS looks for when trying to execute a program.
11Using EDIT to Write Batch Files
- To write a batch file
- must use a program
- that creates ASCII
- text files.
12Using EDIT to Write Batch Files
- Word processing programs can create text files,
but - they are very large
- they take a long time
- to load into memory
13Using EDIT to Write Batch Files
- EDIT is the small, simple text editor in MS-DOS
used to write batch files.
14Using EDIT to Write Batch Files
- Notepad is the text editor in Windows that can be
used to write batch files.
15(No Transcript)
16Writing and Executing a Batch File to Save
Keystrokes
- It is sometimes easier to use COPY CON instead of
EDIT to write a simple batch file.
17Writing and Executing a Batch File to Save
Keystrokes
- Two drawbacks to using COPY CON
- Cannot correct errors
- once ltEntergt is pressed
- Cannot correct errors in
- existing files
18Writing and Executing a Batch File to Save
Keystrokes
- Must use EDIT to correct errors.
19(No Transcript)
20Using Batch Files to Load Application Software
- To launch an application in Windows
- click program icon
- select program from
- menu
- use the toolbar
21Using Batch Files to Load Application Software
- To launch an application program from the command
line - must create a batch file
22Using Batch Files to Load Application Software
- Need to follow three steps in order to load
application software in MS-DOS.
23(No Transcript)
24Writing a Batch File to Load an Application
Program
- By creating a batch file, a user can simplify the
process of loading an application program in
MS-DOS.
25(No Transcript)
26Creating Shortcuts for Batch Files on the Desktop
- To run a batch file from Windows
- click file name in
- Explorer/My Computer
- create shortcut for file
- and place on desktop
27(No Transcript)
28Special Batch File Commands
- There are nine commands specifically designed to
be used in batch files.
29Special Batch FileCommands
30Special Batch File Commands
31Special Batch FileCommands
32The REM Command
- REM command (remarks)...
- statements keyed in by user that tell what is
the purpose of the batch file
33(No Transcript)
34The ECHO Command
- ECHO command
- displays a command and the output of that
command to the screen. -
35The ECHO Command
- The default value for ECHO is ON.
36The ECHO Command
- Can turn off the display of the command and only
see the output of the command.
37The ECHO Command
38(No Transcript)
39Activity Using ECHO
40The PAUSE Command
- PAUSE command
- instructs the batch file to stop executing
until the user takes some action.
41(No Transcript)
42Stopping a Batch File from Executing
- Two ways to interrupt a batch file during
execution - Press ltCtrlgt C
- Press ltCtrlgt ltBreakgt
43(No Transcript)
44Replaceable Parameters in Batch Files
- Many commands use variable or replaceable
parameters.
45Replaceable Parameters in Batch Files
- Batch files can also use replaceable parameters.
46Replaceable Parameters in Batch Files
- Replaceable parameters are used to limit the
number of batch files that do the same thing, but
use different names.
47Replaceable Parameters in Batch Files
- Place holders are needed to indicate to the batch
file that a variable (file name) will be keyed in.
48Replaceable Parameters in Batch Files
- The place holder used in batch files is the
percent sign (), followed by a number (0-9).
49Replaceable Parameters in Batch Files
- The sign is a signal to the OS that a parameter
is coming.
50Replaceable Parameters in Batch Files
- The numbers (0-9) indicate what position the
parameter is on in the command line.
51(No Transcript)
52Multiple Replaceable Parameters in Batch Files
- Many commands used in batch files may require
more than one parameter.
53Multiple Replaceable Parameters in Batch File
- Batch files can have up to 10 replaceable
parameters (0-9).
54(No Transcript)
55Activity Using Multiple Replaceable Parameters
56Creating Useful Batch Files
- With batch files a user can create new commands
that are not provided by the OS.
57(No Transcript)
58Understanding AUTOEXEC.BAT
- AUTOEXEC.BAT is a file that
- runs when the system
- is booted
- contains specific
- commands that a user
- chooses to run
59Understanding AUTOEXEC.BAT
- Interactive booting
- user is asked by the computer if s/he
wants to execute each line in the CONFIG.SYS
and AUTOEXEC.BAT files.
60(No Transcript)
61Controlling the Boot Process
- During booting process, the user may experience
problems that are related to instruction
statements in the CONFIG.SYS or AUTOEXEC.BAT
files.
62Controlling the Boot Process
- By pressing certain function keys, the user can
control the boot process in order to correct
problems that arise.
63(No Transcript)