Batch Script

Why Trust Techopedia

What Does Batch Script Mean?

A batch script is a text file that contains certain commands that are executed in sequence. It is used to simplify certain repetitive tasks or routines in the Windows, DOS and OS/2 operating systems, and is also used in complex network and system administration.

Advertisements

A batch script has a file extension of .bat, .cmd or .btm.

Techopedia Explains Batch Script

The commands in a batch file are executed by a special interface or shell. These commands may include “goto,” “for,” “call,” “echo,” “setlocal,” etc., and may make use of decision and loop constructs. A batch script can be created using any text editor such as Notepad or WordPad, and must be saved only in plain text format.

A batch file can be run easily by clicking on it or by typing its name in a command line interpreter. A batch script can also be run with arguments. The following are some of the commonly used commands in a batch script:

  • Echo — To display some text on the screen
  • Call — To run a batch script from within another script
  • Goto — To transfer control or execution sequence to a label or subroutine
  • If — To test a condition
  • Pause — To wait until a key is pressed
  • Rem — To include a comment line in the script
  • Setlocal — To start a local environment
  • Endlocal — To terminate a local environment
  • Shift — To parse the command line arguments in the script
  • Start — To run a script with a default application
  • Xcopy — To copy files and folders
Advertisements

Related Terms

Margaret Rouse
Technology Expert
Margaret Rouse
Technology Expert

Margaret is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages.