Introduction: Making Your First Batch Program

Batch is a language that has been in use for a long time, but can still be programmed and run on any modern Windows PC. It is completely text-based so therefore it is very easy to learn. It is also free because you simply edit the code in Notepad, and save it with a .bat extension so Windows recognizes it as a batch file. In this tutorial, you will learn about a few commands while creating your own "Hello World!" pop-up.

Step 1: The Programming

Now that you are familiar with Batch, we will start making a program with it!

  1. Open up Notepad (all Windows users have this).
  2. Now, on the first line type in "@echo off". Don't worry what these commands mean right now. I will explain later on.
  3. Press the Enter key to create a new line. Type in "echo Hello World!".
  4. Press Enter again and type in "ping localhost -n 5 >nul" on the next line.
  5. Finally, on the line after that, type in "exit".
Now let's learn about the commands you just typed.
@echo off: This command is placed in the beginning of most Batch programs to hide all processes the computer goes through with your program and only displays the output of the commands.
echo: When a space and some text is added to this command, it displays the specified text on the screen.
ping localhost -n 5 >nul: This commands delays the program a specified number of seconds until going on to the next command. In this case, it delays the program for 5 seconds. Without it in this program, the program would exit as soon as it was launched.
exit: This exits the program.
6. Now it's time to save and run it! In Notepad, go to File > Save as... and type in "My First Batch Program". Don't close the "Save as..." window yet, though. Now click on the drop-down that says "Text Documents (*.txt)" and click on "All Files". Go back to the text field and change "My First Batch Program" to "My First Batch Program.bat". Go to the location it was saved at and double click it. It will now run!

Step 2: Congratulations!

You have completed this tutorial! Come back soon for the next one, because I am making a new one as we speak!