Creating and understanding Batch file

A batch file is a kind of script file in DOS, OS/2 and Windows. A sequence of commands for a computer operating system that store in a text file is known as batch file. Its called a batch file because it batches (bundles or packages) into a single file. A batch file is usually created for command sequences for which a user has a repeated need. Commonly needed batch files are often delivered as part of an operating system. You initiate the sequence of commands in the batch file by simply entering the name of the batch file on a command line.

A batch file has the file name extension “BAT”. In UNIX-based operating systems, a batch file is called a shell script. In IBMs mainframe VM operating systems, its called an EXEC.

Creating bat file

Create a new text document on your desktop. Double click the file – it should be blank inside. Now, go to file>save as, and in the “Save As” window, input a name for your BAT file and then add a “.bat” on the end

Understanding very Basic Command for starting writing a batch file

TITLE – BAT file Window name
ECHO – the “print” statement for BAT files. This display as text in cmd. Example echo “hello world”
ECHO OFF– By this the program wont show the command that you told it to run. Only program activity that you want
PAUSE – BAT file execution paused here. And displaying text “press any key to continue…”. People typically put this in BAT files to give the user a chance to review the material on the screen before continuing.
CLS– Clears the window

Now Start with some code for our batch file. Edit batch file by open it with notepad. Then write some command like below-

Save the file you just coded, and double click it. Your output should be something like the screenshot below.

If you want to learn more about bat files, I had recommend you check out the commands available to the language

Leave a Reply

Your email address will not be published. Required fields are marked *