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
Editor

Margaret jest nagradzaną technical writerką, nauczycielką i wykładowczynią. Jest znana z tego, że potrafi w prostych słowach pzybliżyć złożone pojęcia techniczne słuchaczom ze świata biznesu. Od dwudziestu lat jej definicje pojęć z dziedziny IT są publikowane przez Que w encyklopedii terminów technologicznych, a także cytowane w artykułach ukazujących się w New York Times, w magazynie Time, USA Today, ZDNet, a także w magazynach PC i Discovery. Margaret dołączyła do zespołu Techopedii w roku 2011. Margaret lubi pomagać znaleźć wspólny język specjalistom ze świata biznesu i IT. W swojej pracy, jak sama mówi, buduje mosty między tymi dwiema domenami, w ten…