|
This article is about DOS, OS/2 and Windows scripting. For other types of batch programming, see shell script.
In DOS, OS/2, and Microsoft Windows, a batch file is a text file containing a series of commands intended to be executed by the command interpreter. When a batch file is run, the shell program (usually DOS batch files have the filename extension
HistoryThe command interpreters provide two distinct modes of work: interactive mode (in which the user types commands at a command prompt which are then executed immediately) and batch mode (which executes a predefined sequence of commands). The original concepts for both modes draw ideas from Unix shells, as well as other text-based command line interfaces from the early 1980s such as CP/M which in turn took much of their inspiration from TOPS-10 and TOPS-20 from Digital Equipment Corporation. Microsoft DOS and Windows batch programming has evolved along with the product releases of these operating systems. Although a batch file is analogous to a shell script in Unix-like operating systems, the limited syntax and commands available means it is less suited for general-purpose programming. These limitations led to various non-Microsoft interpreters to provide enhanced syntax by providing "enhancement" commands such as those in the Norton Utilities (like the BE or Batch Enhancer) and in 1989 the replacement shell 4DOS and later 4NT. DOSThe batch program interpreter for MS-DOS and compatible DOSes is The evolution of this branch of batch programming proceeded through the releases of MS-DOS, and continued with the early versions of Microsoft Windows through to Windows 95, Windows 98, and finally Windows Me, which remained based on MS-DOS. Modern WindowsModern versions of Microsoft Windows such as Windows XP and Windows Vista are not based on MS-DOS, but on Windows NT. NT-based systems's native command line interpreter is For complex tasks in Windows 98 and up the Windows Script Host may be used. It allows the running of scripts written in VBScript, JScript and related scripting languages, but is more akin to traditional programming languages. It has no command line interface. In 2006, Microsoft created another scripting tool, Windows PowerShell, which can be used with Windows XP and above. It is also designed for interactive use from command line interface. OS/2Although the IBM OS/2 operating system did support DOS-style batch files, it contained a version of REXX — a more advanced scripting language. ExampleAn example of a simple batch file: REM ECHO OFF prevents the printing of each command to standard output. @ECHO OFF REM ECHO. prints a blank line. ECHO. ECHO Hello World, press any key to start APROGRAM.EXE! PAUSE > NUL REM The first argument to the batch file can be referenced with "%1" APROGRAM.EXE %1 IF ERRORLEVEL 1 GOTO error ECHO. ECHO APROGRAM has finished whatever it was doing. GOTO end :error ECHO. ECHO Something went wrong with AProgram. :end PAUSE See also
External linksWikibooks has a book on the topic of
Article keywords: dos batch file, |
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License.
Mercedes Car
This site monitored by SitePinger.net