edit] Modern Windows
Modern 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 CMD.EXE
which, while generally compatible with MS-DOS, provides many additional features and commands. (The older COMMAND.COM
of MS-DOS is still available on NT-based systems where necessary for better backward compatibility.) It is a common myth that .bat are run by COMMAND.COM while .cmd are run by CMD.EXE. Nevertheless, there are differences between the .bat and .cmd extensions which affect when errorlevels are set.[1]
For complex tasks in Windows 98 and up the Windows Host may be used. It allows the running of s written in VB, J and related ing languages, but is more akin to traditional programming languages. It has no command line interface.
In 2006, Microsoft created another ing tool, Windows PowerShell, which can be used with Windows XP and above. It is also designed for interactive use from command line interface.
A modern way of securely distributing batch files is to compile them to executables. Some BAT to EXE compilers encrypt the s so they cannot be viewed with a normal text editor.
Although the IBM OS/2 operating system supported DOS-style batch files, it also included a version of REXX — a more advanced ing language.
[edit] Example
An example of a simple batch file:
@echo off
cls
echo Hello World!
echo.
pause
This batch file would first turn off "echo". This only s the output of the command on the screen, not the input (EXAMPLE: Input: pause --- Output: Press Any Key To Continue.). Then, it would clear the screen after the echo off command (cls
), then it would a line of text "Hello World!" (echo Hello World!
), then an empty line below it (echo.
), then it would keep the screen open until the user presses any key with the message "Press any key to continue.