Power of Batch Programming


Have you ever thought of how computer viruses delete loads of file in a second without your permission or a loop of folder gets created on your disk or having a program that can execute automatically on logging in your PC or why that black screen with white text pops up while installing games or software? The first thing in mind that comes is that there must be lines of code or programming behind it, exact! This all and a lot more can be achieved using Batch File Programming which is pretty much easier to learn and very simpler to run. So let’s dive into what it is and have a pump up knowledge about making batch file.

What is Batch File Programming or Batch Scripts?

In general, we can say that it is the programming language offered by Microsoft Windows OS, DOS and OS/2 which has built-in commands sequence to do some specific task or to automate certain tasks one after other.

Technically speaking, in DOS, OS/2, and Microsoft Windows, batch file contains series of commands written in a script file or a text file that is executed by command interpreter.

Inside Batch Files or Batch Scripts!

Batch files has built-in commands written line by line via a text editor like notepad, wordpad or winword and then saved by .bat or .cmd (for Windows NT based OS) and .btm (used by 4DOS and 4NT). Don’t be panic with 4DOS and 4NT, they are just command line interpreter that executes the code written in bath files. A simple code snippet for a batch file is as follows:

@echo off

echo Happy New Year, welcome 2014!


Instead of Happy New Year, welcome 2014! you can write whatever you want to see as output, that’s what echo does, it shows anything written after it as a message on command prompt. The code can be written in any text editor (notepad, wordpad or winword) and saved by .bat or .cmd extension and gets executed on running the saved file. Each line in code imparts a specific meaning and gives instruction to COMMAND line interpreter to perform a specific task. Diving into the details about how it gets printed or what each line of code means will be taking you off the shores from this post.

If you don’t know how to save by a particular extension, then these snaps are for you:

  1. Click on File, then save as.
  2. save as particular extension in notepad

    File -> Save as

  3. Save by filename.bat, where filename is the name you want for your script and .bat is the extension for batch file.
saving as .bat extension


What we get?

This is the most essential part of any programming or script as we want to see what we want and in this the above case, we want the computer to print Happy New Year, welcome 2014! on the command prompt when this file gets executed.

command prompt output screen

Happy New Year 2014 output

The output thus, prints Happy New Year, welcome 2014!  on command prompt screen or console screen as expected.

This batch program is the simplest and the most basic program to get an idea about what batch programming does. At the starting of this post, I talked about viruses, software and games installation, they do get executed in the same way as there are several lines of these built-in commands written into a single or multiple batch files. So hang on for a series of tutorials that will help you understand better that how it works and a lot more geeky programs that will amaze you.

In all, the Power of Batch Programming lies in the fact that it directly deals with your Operating System environment and executes sequential in-built commands written in a specific way. As in Windows, it’s Batch scripts, for Linux/Unix, there is Shell Scripts.

Hang on for getting geeky.

Get the best of Durofy in your inbox


About Author

Blogging, coding, gaming (DoTA2), music and hangouts that's it :D

Comments are closed.