[Batch] Batch Programming #1: Commands of Batch File and Make a Hello World Program

Batch is a simple programming language used in Dos, OS/2 and MS Windows.
Let's learn the basic of it!


Basic Commands:

1. @Echo On / @Echo Off:
@Echo off means that it will turn off the default command echoing.
@Echo On is the opposite.

2. Echo text:
Echo text is used to display the text to the user on the command prompt.

3. Pause
Pause is commonly used in the last line of a batch file. It pauses the script's execution and display Press any key to continue... . Once the user click a key, the program will continue the execution or terminates the program if no more code is found below the pause.

Making a Hello World Program
  1. Open a notepad.

  2. On the first line, type "@Echo off" (without quotation marks). This disables the default echoing of the command prompt program.

  3. On the second line, type "echo Hello World!" (without quotation marks). This will display the word "Hello World!"

  4. At the last line, type in "pause". This will pause the code's execution and display the word to the user.

  5. Save the file as hello-world.bat
Results: 

After clicking any key on your keyboard, the program will terminate.

In the next post, we will apply text and background color to a batch file.

0 comments:

Post a Comment