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
- Open a notepad.
- On the first line, type "@Echo off" (without quotation marks). This disables the default echoing of the command prompt program.
- On the second line, type "echo Hello World!" (without quotation marks). This will display the word "Hello World!"
- At the last line, type in "pause". This will pause the code's execution and display the word to the user.
- Save the file as hello-world.bat
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