8
Command Prompt Chapter 10 Introduction to Batch Files Richard Goldman February 7, 2000

Command Prompt Chapter 10 Introduction to Batch Files Richard Goldman February 7, 2000

Embed Size (px)

Citation preview

Page 1: Command Prompt Chapter 10 Introduction to Batch Files Richard Goldman February 7, 2000

Command PromptChapter 10

Introduction to Batch Files

Richard Goldman

February 7, 2000

Page 2: Command Prompt Chapter 10 Introduction to Batch Files Richard Goldman February 7, 2000

Batch File• A batch file is an ASCII text file that contains a

list of commands that the operating system can execute.

• A batch file must end with a .BAT extension.• A batch file is run by entering its name at the

command prompt.• A batch file may be interrupted by pressing

[Ctrl] + C

or

[Ctrl] +[Break].

Page 3: Command Prompt Chapter 10 Introduction to Batch Files Richard Goldman February 7, 2000

Creating a Batch File

• Batch files can be written with any word processor or editor that can save files in ASCII text format.

• The MS DOS editor if often used while in DOS for working with batch files.

• You may also use theCOPY CON [filename.bat]

to write simple BAT files.

Page 4: Command Prompt Chapter 10 Introduction to Batch Files Richard Goldman February 7, 2000

Batch file Commands• Call – Calls another batch file• CHOICE – Pauses file and asks user to enter a

response to a question. (Not available in Win 2000)• ECHO – Displays or hides text.• FOR – Runs a command for files in a set.• GOTO – Directs flow to specified label.• IF – Conditional processing.• PAUSE – Temporally stops processing.• REM – Used to document batch file.• SHIFT – Shifts replaceable parameters

Page 5: Command Prompt Chapter 10 Introduction to Batch Files Richard Goldman February 7, 2000

REM Command

• Used to document a batch file.

• No action will be taken on lines that start with a REM statement.

Page 6: Command Prompt Chapter 10 Introduction to Batch Files Richard Goldman February 7, 2000

Replaceable Parameters

• Allows users to enter variables at the command prompt that the batch file can use.

• You can reference parameters 1-9 (0 is the position of the command).

• Substitute % followed by the entry order number of the parameter.

• Example: %3

Page 7: Command Prompt Chapter 10 Introduction to Batch Files Richard Goldman February 7, 2000

AUTOEXEC.BAT File

• The AUTOEXEC.BAT file is automatically run after the system is booted in Win 9X.

• Not used with NT Operating Systems.

• The system looks for it in the root directory.

Page 8: Command Prompt Chapter 10 Introduction to Batch Files Richard Goldman February 7, 2000

End