Batch file
From Seo Wiki - Search Engine Optimization and Programming Languages
| This article needs additional citations for verification. Please help improve this article by adding reliable references. Unsourced material may be challenged and removed. (May 2009) </td> </tr> </table>
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 .bat. Batch files for other environments may have different extensions, e.g. .cmd or .bat in the Microsoft Windows NT-family of operating systems and OS/2, or .btm in 4DOS and 4NT related shells. The now-obsolete Windows 9x family of operating systems only recognize the .bat and .btm extension.
[edit] HistoryOriginally command interpreters' primary responsibility was to execute out commands entered manually. Such commands might involve starting programs, carrying out file operations, executing functions concerned with controlling the system, setting preferences or administrative tasks. Sequences of such commands were also sometimes stored in files, which could be later passed to the command interpreter to be read and executed, so such stored sequences could be termed sets of 'batch commands'. Over time, command interpreters or 'shells' grew additional features, as such stored sequences of such 'batch commands' became more complex, and command interpreters evolved into something more akin to interpreters for a kind of limited programming languages or 'script'. Additional commands, advanced syntactic features and computation abilities were added which allowed sophisticated programs to be written so that batch files or scripts could contain a mixture of commands of the traditional. [edit] Early influencesMicrosoft DOS batch language was influenced by various 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. Although a DOS batch file is analogous to a shell script in Unix-like operating systems, the syntax and range of commands available is less sophisticated. [edit] DOSThe first example of Microsoft's batch files were the .bat files used by DOS. The operating system used An example of an important batch file was [edit] Enhancements and alternativesThe limitations of the DOS command intrepreter 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), in 1989 the replacement shell 4DOS. [edit] Early WindowsMicrosoft Windows was introduced in 1985 as a GUI Operating System alternative to text-based operating and was designed to run on MS-DOS. In order to start it the Windows was based on MS-DOS and used
[edit] OS/2The IBM OS/2 operating system supported DOS-style batch files. It also included a version of REXX, which was a more advanced scripting language. IBM and Microsoft started developing this system but during the construction of it broke up after a dispute, as a result of this IBM referred to their MS-DOS like console shell without mention of Microsoft; naming it just DOS, although this seemingly had no impact on the way batch files worked. [edit] Windows NTThe Microsoft Windows NT-family of operating systems featured a second, new command interpreter [edit] Filename extensions
[edit] DifferencesThe only known difference between .cmd and .bat file processing is that in a .cmd file the [edit] Exampleex.1 @echo off title Hello World echo Hello World echo. pause To execute the file it must be saved with a .bat or .cmd extension in plain text format (with a program like Notepad). ex.2 @echo off color A title Conditional Shutdown :start cls set /p name=enter a name: cls echo Hi, %name% echo. echo 1.Shutdown echo 2.Quit set /p choice=enter your choice 1,2: if %choice%==1 goto shutdown if %choice%==2 exit :shutdown cls set /p sec=enter the amount of seconds that you wish the computer to shutdown in: set /p msg=enter the shutdown message you wish to display: shutdown -s -f -t %sec% -c %msg% echo shutdown initiated at %time% set /p cancel=type cancel to stop shutdown if %cancel%==cancel shutdown -a if %cancel%==cancel goto start [edit] ResultWhen executed (either from Windows Explorer or Command Prompt) this is displayed: ex.1 Hello World! Press any key to continue . . . ex.2 enter a name: [edit] ExplanationBatch files are executed by every line being executed in order until the end is reached or something else stops it (such as the key shortcut for terminating batch processing; 'Ctrl' + 'C'). This batch file first turns off the 'echo' with [edit] FutureMicrosoft hasn't officially released information pertaining to the future of Command Prompt (host for .bat and .cmd files) yet, but the company is now starting to include Windows PowerShell in releases for newer Operating Systems, which has all the core functions of Command Prompt and more (and instead of .bat and .cmd files, it runs .ps1 files). Yet it is important to remember that it is not certain this will replace Command Prompt, and that Microsoft is still making important tools for Command Prompt specifically, instead of for PowerShell (such as [edit] Other Windows scripting languagesIn addition to traditional batch files, the need for more powerful capabilities has led to the development of other Windows-specific scripting languages:
In addition to these, powerful cross platform scripting tools such as Perl, Python, and Rexx are now available for Windows. [edit] See also
|