Batch scripts are stored in simple text files containing lines with commands that get executed in sequence, one after the other. These files have the special extension BAT or CMD. Files of this type are recognized and executed through an interface (sometimes called a shell) provided by a system file called the command interpreter. In Windows XP and later versions of Windows the command interpreter is the file
cmd.exe. The large assortment of versatile commands available in Windows XP and later versions of Windows, makes batch files a powerful tool.
Because scripts contain standard text characters, you can create and edit scripts using a standard text editor, such as Notepad. When you enter commands, be sure to place each command or group of commands that should be executed together on a new line. This ensures proper execution of the commands. When you have finished creating a batch script, save the script file using the .bat or .cmd extension. Both extensions work with batch scripts in the same way.
Running a batch script file is a simple matter of just double-clicking on it. Batch files can also be run in a Command Prompt. In such case, the full path name must be used unless the file's path is in the path environment.
To become an effective Windows batch script programmer, you must become intimately familiar with the Windows Command Prompt. The Windows Command Prompt is a text-based interface to the Windows operating system as opposed to the Windows desktop, which is a GUI-based interface.
The Windows Command Prompt accepts user commands and translates them into a format that can be processed by the operating system. It then displays any output returned by the operating system back in the Windows Command Prompt console.
Open the Command Prompt by clicking
Start Menu --> All Programs --> Accessories. In Windows Vista and later versions of Window operating systems type
cmd.exe into Start Screen or Start Menu.
To execute a command at Command Prompt, type it in at the Command Prompt and press the Enter key. For example, to display the contents of the current working directory, type
DIR and press Enter key.