Writing a Windows batch
script
In Windows, the batch file is a file that stores commands in a serial
order. The command line interpreter takes the file as an input and
executes in the same order. A batch file is simply a text file saved with
the .bat file extension. It can be written using Notepad or any other
text editor.
A simple batch file will be.
// When echo is turned off, the command prompt doesn't appear in the
Command Prompt window.
ECHO OFF
// The following command writes Example to the console.
ECHO Example
// The following command suspends the processing of a batch program and
displays the prompt.
PAUSE
script, ECHO off cleans up the console by hiding the commands from being
printed at the prompt, ECHO prints the text “Example” to the screen, and
then waits for the user to press a key so the program can be ceased. Some
basic commands of batch file:
• ECHO – Prints out the input string. It can be ON or OFF, for ECHO to turn
the echoing feature on or off. If ECHO is ON, the command prompt will
display the command it is executing.
• CLS – Clears the command prompt screen.
• TITLE – Changes the title text displayed on top of prompt window.
• EXIT – To exit the Command Prompt.
• PAUSE – Used to stop the execution of a Windows batch file.
• :: – Add a comment in the batch file.
• COPY – Copy a file or files.