Batch Files

Batch Files

Sections: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Index | Next >

Basic Batch File Commands

Learning objective: (1) Identify common batch file commands


Click on image to enlarge.

Special batch file commands include: REM for placing remarks in the batch file to the developer, ECHO display information to user, replaceable parameters allow data to be passed from the command line into the batch file, GOTO allows the processing to jump to a new location in a batch file, labels name a section in a batch file, IF select different courses of action to be taken, and START allows you to start a Windows application from inside a batch file. (Technically, START is *not* a batch file command but is often used in batch files so we will introduce it here.) There are many other special batch commands that we will not be covering.

REM

The REM command allows developers to enter a comment into the batch file which will only be seen when the code is opened in a text editor.

ECHO

The ECHO command will allow text and other events to be displayed to the console during execution.

GOTO

The GOTO command allows the project to jump to new locations identified by a :label in the batch file. This command is usually associated with the IF command.

IF

The IF command allows for different actions to be taken during execution based on changes in the environment. This command is usually associated with passing parameters.

START

The START command will allow a Windows application to start and run in the GUI window.

%n passing parameters (0-9)

Passing parameters allow data to be passed at run time from the command line into the batch file. This data can be used by the IF command to determine what the batch file should do.

Thinking: Why are there special commands just for batch files?

Key terms: ECHO, GOTO, IF, START, commands, parameters

Resources:
To maximize your learning, please visit these Web sites and review their content to help reinforce the concepts presented in this section.

Quick links:
Information on batch files @ computerhope.com

Embedded Resources

Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.

Information on batch files @ computerhope.com | Reload page | If frame is empty, click on the link to view the page in a new tab or window

Sections: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Index | Next >