Home > Articles > Home & Office Computing > Microsoft Windows Desktop

  • Print
  • + Share This
This chapter is from the book

Batch File Programming

In the following sections, I'll discuss programming techniques that take advantage of the extended commands provided by the CMD shell. The commands that are most useful in batch files are listed in Table 12.1.

Table 12.1. Batch File Commands

Command

Use

call

Calls batch file subroutine

echo

Displays text to the user

setlocal/endlocal

Saves/restores environment variables

exit

Terminates batch file

for

Iterates over files or folders

goto

Used for flow control

if

Executes commands conditionally

pause

Lets the user read a message

pushd/popd

Saves/restores the current directory

rem

Used for comments and documentation

set

Sets environment variables, performs calculations, and prompts for user input

shift

Scans through command-line arguments

start

Launches a program in a different window

The syntax and options for these commands were described in Chapter 11. If you've written batch files for DOS, Windows 9x, and Windows NT, you'll find that most of these commands have been significantly enhanced, so even if you are familiar with these commands, you should read their descriptions in Chapter 11.

  • + Share This
  • 🔖 Save To Your Account