loading
If you know how to run commands in the
command prompt, you’ll be a wiz at creating BAT files because it’s the same language. All you’re doing is telling the command prompt what you want to put in through a file, rather than typing it every time you run the command prompt. This saves you time and effort; but it also allows you to put in some logic (like simple loops, conditional statements, etc. that procedural programming is capable of conceptually).

There are SEVEN simple commands I want to familiarize you with for this program. Commands are NOT case sensitive, so don’t worry about that.

TITLE - The Window name for the BAT file.

ECHO - the “print” statement for BAT files. Anything following the word ECHO will be displayed in the command prompt as text, on its own line.

ECHO OFF – BAT writers typically put this at the beginning of their files. It means that the program won’t show the command that you told it to run while it’s running – it’ll just run the command. I’d recommend that after you run this test program, you try removing this line from your code to see what happens.

PAUSE - This outputs the “press any key to continue…” message that you’ve seen all too many times. It’s helpful because it pauses the BAT file execution until the user tells it to go again. If you don’t put this in your program, everything will speed by and end before you can see it. People typically put this in BAT files to give the user a chance to review the material on the screen before continuing.

CLS - Clears the DOS window (helpful if things get too cluttered!).

IPCONFIG – Outputs a lot of network information into your DOS box (network admins have dreams solely based off this command).

PING - Pings an IP, letting you know if your computer was able to contact it. This command also returns the latency (ping time) and by default pings three times.

Step 1: Some Other Basic Batch File Command

These are some other batch file commands that you will need to know.


ECHO OFF
::CMD will no longer show us what command it’s executing(cleaner)

ECHO Hello
::Prints some text

IPCONFIG /ALL
:: Outputs tons of network information into the command prompt

PING www.website name.com,org,gov,
:: Pings the website you want and gives you the website ip.

PAUSE
:: Give the user some time to see the results. Because this is our last line, the program will exit and the command window will close once this line finishes.
<p>Interesting, thank you for sharing.</p>

About This Instructable

599views

21favorites

License:

More by FailzJC:How to Write Basic Batch Files 
Add instructable to: