Ch 101 Chapter 10 Introduction to Batch Files. Ch 102 Overview A batch file is a text file that...
-
Upload
cora-bryan -
Category
Documents
-
view
224 -
download
0
Transcript of Ch 101 Chapter 10 Introduction to Batch Files. Ch 102 Overview A batch file is a text file that...
Ch 10 1
Chapter 10Chapter 10
Introduction to Batch Files
Ch 10 2
OverviewOverview
A batch file is a text file that contains an ordered
series of commands.
Ch 10 3
OverviewOverview
Batch files allow the user to …
automate a process create more powerful commands
Ch 10 4
Concepts Concepts ofof Batch Batch & Interactive Processing& Interactive Processing
A batch file contains one or more commands.
Ch 10 5
Concepts Concepts ofof Batch Batch & Interactive Processing& Interactive Processing
A batch file must have the extension .BAT
Ch 10 6
Concepts Concepts ofof Batch Batch & Interactive Processing& Interactive Processing
Batch files allow the user to …
minimize keystrokes minimize the possibility of errors
Ch 10 7
Concepts Concepts ofof Batch Batch & Interactive Processing& Interactive Processing
In interactive processing (real-time mode) …
the user directly interacts with computer info. is processed without delay
Ch 10 8
How Batch Files How Batch Files WorkWork
The difference between Data and Program files is determined by their file
extensions.
Ch 10 9
How Batch Files How Batch Files WorkWork
Priority rules are followed when the OS looks for a file to load and execute.
Ch 10 10
How Batch Files How Batch Files WorkWork
The .BAT extension is the last file extension the OS looks for when trying to
execute a program.
Ch 10 11
Using Using EDITEDIT to to Write Batch FilesWrite Batch Files
To write a batch file … must use a program that creates ASCII text files.
Ch 10 12
Using Using EDITEDIT to to Write Batch FilesWrite Batch Files
Word processing programs can create text files, but …
they are very large they take a long time to load into memory
Ch 10 13
Using Using EDITEDIT to to Write Batch FilesWrite Batch Files
EDIT is the small, simple text editor in MS-DOS
used to write batch files.
Ch 10 14
Using Using EDITEDIT to to Write Batch FilesWrite Batch Files
Notepad is the text editor in Windows that can be used to write batch files.
Ch 10 15
Activity:Activity: WritingWritingand Executing aand Executing a
Batch FileBatch File
. . .
Ch 10 16
Writing and Executing Writing and Executing a Batch File to Save a Batch File to Save
KeystrokesKeystrokes
It is sometimes easier to use COPY CON instead of EDIT
to write a simple batch file.
Ch 10 17
Writing and Executing Writing and Executing
a Batch File to Save a Batch File to Save KeystrokesKeystrokes
Two drawbacks to using COPY CON:
Cannot correct errors once <Enter> is pressed Cannot correct errors in existing files
Ch 10 18
Writing and Executing Writing and Executing a Batch File to Save a Batch File to Save
KeystrokesKeystrokes
Must use EDIT to correct errors.
Ch 10 19
Activity:Activity: Writing andWriting andExecuting a One-Executing a One-Letter Batch FileLetter Batch File
. . .
Ch 10 20
Using Batch FilesUsing Batch Files toto Load Application Load Application
SoftwareSoftwareTo launch an application in Windows …
click program icon select program from menu use the toolbar
Ch 10 21
Using Batch Files to Using Batch Files to Load Application Load Application
SoftwareSoftwareTo launch an application program from the command line …
must create a batch file
Ch 10 22
Using Batch Files to Using Batch Files to Load Application Load Application
SoftwareSoftware
Need to follow three steps in order to load application
software in MS-DOS.
Ch 10 23
Activity:Activity: Using theUsing theHPB ApplicationHPB Application
PackagePackage
. . .
Ch 10 24
Writing a Batch File Writing a Batch File to Load an to Load an
Application ProgramApplication Program
By creating a batch file, a user can simplify the process of
loading an application program in MS-DOS.
Ch 10 25
Activity:Activity: Writing aWriting aBatch File to ExecuteBatch File to Execute
HPBHPB
. . .
Ch 10 26
Creating Shortcuts for Creating Shortcuts for Batch Files on the Batch Files on the
DesktopDesktopTo run a batch file from Windows:
click file name in Explorer/My Computer create shortcut for file and place on desktop
Ch 10 27
Activity:Activity: CreatingCreatinga Shortcut on thea Shortcut on the
DesktopDesktop
. . .
Ch 10 28
Special Batch File Special Batch File CommandsCommands
There are nine commands specifically designed to be used in batch files.
Ch 10 29
Special Batch FileSpecial Batch FileCommandsCommands
CALL CHOICE ECHO
Ch 10 30
Special Batch File Special Batch File CommandsCommands
FOR GOTO IF
Ch 10 31
Special Batch FileSpecial Batch FileCommandsCommands
PAUSE REM SHIFT
Ch 10 32
The REM CommandThe REM Command
REM command (remarks)...statements keyed in by user that tell what is the purpose of the batch file
Ch 10 33
Activity:Activity: UsingUsingREMREM
. . .
Ch 10 34
The The ECHOECHO CommandCommand
ECHO command …
displays a command and the output of that command
to the screen.
Ch 10 35
The The ECHOECHO CommandCommand
The default value for ECHO is ON.
Ch 10 36
The The ECHOECHO CommandCommand
Can turn off the display of the command and only see the output of the command.
Ch 10 37
The The ECHOECHO CommandCommand
Ch 10 38
Activity:Activity: UsingUsingECHOECHO
. . .
Ch 10 39
Activity: Activity: Using Using ECHOECHO
Ch 10 40
The The PAUSEPAUSE CommandCommand
PAUSE command …instructs the batch file to stop executing until the user takes some action.
Ch 10 41
Activity:Activity: UsingUsingPAUSEPAUSE
. . .
Ch 10 42
Stopping a Batch File Stopping a Batch File from Executingfrom Executing
Two ways to interrupt a batch file during execution:
Press <Ctrl> + C Press <Ctrl> + <Break>
Ch 10 43
Activity:Activity: Quitting aQuitting aBatch FileBatch File
. . .
Ch 10 44
Replaceable Replaceable Parameters in Batch Parameters in Batch
FilesFiles
Many commands use variable or replaceable
parameters.
Ch 10 45
Replaceable Replaceable Parameters in Batch Parameters in Batch
FilesFiles
Batch files can also use replaceable parameters.
Ch 10 46
Replaceable Replaceable Parameters in Batch Parameters in Batch
FilesFilesReplaceable parameters are
used to limit the number of batch files that do the
same thing, but use different names.
Ch 10 47
Replaceable Replaceable Parameters in Batch Parameters in Batch
FilesFilesPlace holders are needed to
indicate to the batch file that a variable (file name)
will be keyed in.
Ch 10 48
Replaceable Replaceable Parameters in Batch Parameters in Batch
FilesFilesThe place holder used in batch files is the percent sign (%), followed by a
number (0-9).
Ch 10 49
Replaceable Replaceable Parameters in Batch Parameters in Batch
FilesFilesThe % sign is a signal to the OS that a parameter is
coming.
Ch 10 50
Replaceable Replaceable Parameters in Batch Parameters in Batch
FilesFilesThe numbers (0-9) indicate
what position the parameter is on in the
command line.
Ch 10 51
Activity:Activity: UsingUsingReplaceableReplaceableParametersParameters
. . .
Ch 10 52
Multiple Replaceable Multiple Replaceable Parameters in Batch Parameters in Batch
FilesFilesMany commands used in
batch files may require more than one parameter.
Ch 10 53
Multiple Replaceable Multiple Replaceable Parameters in Batch Parameters in Batch
FileFileBatch files can have up to 10 replaceable parameters
(%0-%9).
Ch 10 54
Activity:Activity: UsingUsingMultiple ReplaceableMultiple Replaceable
ParametersParameters
. . .
Ch 10 55
Activity: Activity: Using Using Multiple Replaceable Multiple Replaceable
ParametersParameters
Ch 10 56
Creating Useful Creating Useful Batch FilesBatch Files
With batch files a user can create new commands that
are not provided by the OS.
Ch 10 57
Activity:Activity: WritingWritingUseful Batch FilesUseful Batch Files
. . .
Ch 10 58
Understanding Understanding AUTOEXEC.BATAUTOEXEC.BAT
AUTOEXEC.BAT is a file that …
runs when the system is booted contains specific commands that a user chooses to run
Ch 10 59
Understanding Understanding AUTOEXEC.BATAUTOEXEC.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.
Ch 10 60
Activity:Activity: Writing andWriting andUsing anUsing an
AUTOEXEC.BATAUTOEXEC.BAT File File
. . .
Ch 10 61
Controlling the Controlling the Boot ProcessBoot Process
During booting process, the user may experience problems that are related to instruction
statements in the CONFIG.SYS or AUTOEXEC.BAT files.
Ch 10 62
Controlling the Controlling the Boot ProcessBoot Process
By pressing certain function keys, the user can control
the boot process in order to correct problems that arise.
Ch 10 63
Activity:Activity: BypassingBypassingAUTOEXEC.BATAUTOEXEC.BAT
. . .