febooti softwarehome of febooti softwarefebooti software

first DOS batch script

Batch files
homenewsproductsdownloadsorderingsupportcontacts
show Quick Links
hide Quick LinksQuick Links: Command line email home | Online help | Commands | Batch files | FAQ | Buy now | Download


Now we are familiar with the command prompt. Batch scripts are written using a text editor. This does not mean Microsoft Word or Microsoft Works or any other of those fancy programs you might use to type up a report. Those types of programs are called word processors, not text editors. Besides the obvious that these programs allow you to change colors and import graphics these programs add extra formatting that you don't see. A great example of a text editor is Notepad. Notepad comes bundled up with Microsoft operating systems. To access Notepad simply click the start button followed by the Programs option. Next, click on Accessories which is usually at the top of the column. The next pop-up column should contain the Notepad program option.

A helpful hint is to make a shortcut to Notepad from your desktop by right-clicking on the Notepad option. Subsequently select Send To followed by selecting Desktop (Create a Shortcut) . This allows quick access in the future by placing an icon on your desktop. A shortcut can also be made using batch. By the end of this article you will be able to create a short-cut in batch.

Now that we have Notepad open we can begin scripting. Let's begin by printing the words "Hello World" to the screen. Type the following into a Notepad screen. Be sure to leave out the numbers and colons. You will learn later that they are just for demonstration purposes. We want to save the file as helloworld.bat

1:
2:
3:
4:
5:
6:
7:
8:
9:



@ECHO OFF

REM helloworld.bat

:: Next line (7) prints Hello World to the screen


ECHO Hello World

PAUSE
Type text Copy text

Now let's explain what each line does. The numbers and colons at left are used to help explain each line. Do NOT enter the numbers and colons into your Batch file.

The computer has a habit of taking everything you type and storing it verbatim. This can be annoying and troublesome at first however you will soon realize that predictability is nice. Anyway, this means that all commands will be seen by the end-user. This makes for a very ugly and bothersome execution.

To circumvent this we will type @ECHO OFF at first line. ECHO OFF makes sure that command echoing is turned off. This fixes our previous problem. However, it creates a new one. ECHO OFF is a command thus it will be seen. That is where the use the @ sign comes in. This stops the echo of the ECHO OFF command. If you were to leave the @ sign out you would see ECHO OFF above your Hello World message as part of your output.

The majority of batch scripts have this snippet of code at the beginning. You can also turn echoing on if you like by using the command ECHO ON. If you type ECHO by itself the status of ECHO will be displayed. The ECHO OFF command only turns off command echoing. DOS commands will still be seen.

When you copy a file in a batch file, you will still see the 1 File(s) copied message. If you use a batch file to start a program that program will indeed appear on the screen. ECHO OFF turns off batch file commands while that specific batch file is running.


Previous DOS batch commandDOS batch command 5 of 11
Return to Origin
Next DOS batch command



Look closer
febooti Command line email: send email directly from DOS command line (DOS prompt)
febooti ieZoom toolbar: zoom Browser pages (Internet Explorer)
febooti fileTweak: utility to change file date and time


How to?
How to send email with / from MS WORD VBA macro
How to send e-mail from command line instead of MAPI
How to send email with / from MS Access VBA


Links
febooti software affiliate program
Link to us!
Links


febooti softwarehome of febooti software
back to top
Copyright © 2001-2006 febooti software. All rights reserved.
Copyright © 2001-2007 febooti software. All rights reserved. Last Updated: August 28, 2005