This group was created by Cody and I to teach the public how to code & program command prompts to create useful and fun codes.

Forum Thread
  Posts  
Batch File Tutorials #1 - The Basics (Groups : Command Prompt Coding & Programing (CPC&P) : Forum : Tutorials : Batch File Tutorials #1 - The Basics) Locked
Thread Options
Sep 10 2009 Anchor

Welcome to the first tutorial in a series of tutorials teaching you how to code or program batch files, also known as command prompts.

Below you will learn:
-codes & functions
-how to use the command prompt

Now to begin. Whenever you pursue an intrest you need dedication and paitence or it fails, right? I thought so. Coding or programing a command prompt is no different.

There are 6 main codes you need to learn before continuing on to more advanced basics:
-@echo on/off
-cls
-echo
-pause
-echo.
-exit

Each code has its' on function which your also need to learn:
-@echo on/off - This code allows you to choose whether or not the "echo" code will appear in the command prompt. If you turn @echo off then "echo" will not appear. If you turn @echo on then "echo" will appear. Simple enough?
-cls - The cls code clears the command prompt screen. It does not effect the code that is in the notepad.
-echo - This code is needed so that dialog will appear in the command prompt.
-pause - The pause code will stop the command prompt and you must press a key before continuing.
-echo. - Will end the "echo" dialog.
-exit - Finally, the exit code will stop the command prompt and exit the command prompt.

Those are the 6 basic codes & functions you will need to know before continuing. Now I'll show you a basic example:
Note that you should try this several times and get a good feel with the basic codes & functions before continuing on.

@echo off
cls
echo Hello there. I'm Justin and I am teaching you how to code & program a command prompt.
echo If this works inside a command prompt and your seeing this you are good to go and may continue on to tutorial #2.
pause
echo.
exit

Now you should type that into notepad exactly how it is. Always remember to start off your batch file with @echo off or on, which ever you prefer. Afterwards, always add cls. That way your presented with a clean and blank command prompt to work with.

In order for any file to be saved as a batch or bat file you need to add ".bat" to the end of it. For example:
Let's say you just spend 30 minutes learning the basics and just created a small code using the above codes & functions.
In order for the notepad file to become a batch file you need to "save as" then whatever you choose to save it as, add ".bat" at the very end. For instance, when I tested this out to make sure it worked I saved as "TutorialTest#1.bat". Also you need to save it on your desktop. So it'll be there and easily accessible.

Thanks for viewing and if you have questions please post them in the "Help" section on the forums. If you have comments & suggestions you can post those in the "Reply" section of this thread.

Keromalas(Justin)

Edited by: Keromalas

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.