home *** CD-ROM | disk | FTP | other *** search
-
- -------------------------------------------------------------------------
- BATCH FILES FOR EFFICIENCY - GETTING THE WORK DONE
- -------------------------------------------------------------------------
-
- A batch file is little more than a series of DOS commands placed into
- a separate file. The commands are simply a list of operations you wish the
- computer to perform. These operations can be DOS operations (e.g.,
- format a disc, display the date and time, etc) or other operations which
- load or start another program. Each line of a batch file contains one
- instruction or operation for the computer to perform. Don't worry about
- understanding the following example, just note that each instruction is
- on a separate line . . .
-
- example:
-
- rem this is the start (a remark displayed on screen)
- date (date displayed)
- time (time displayed)
- ver (DOS version displayed)
- dir a:/p (directory of a: displayed)
- rem now let's load 123 (another remark)
- 123 (start program named 123)
- rem end of batch file (final remark)
-
-
- The primary use of batch files and commands is to automate sequences
- or instructions which you might use frequently. A batch file always has
- the extension BAT (example: autoexec.bat, hello.bat).
-
- Each line in the batch file is a separate command and is performed
- as if you had typed in the command from your keyboard at the DOS
- prompt. In addition to the usual DOS commands, batch files can also
- contain special commands which allow you to build small programs.
- Branching (selecting various directions or choices) and iteration
- (repititions of a command) are allowed within the framework of
- these additional batch commands. In addition, batch files may
- have special parameters or inputs passed to them at the time
- you cause the batch file to execute.
-
- A batch file is started by typing the file name without the extension.
-
- Example: a>hello (starts the file hello.bat)
- Example: c>whoops (starts the file whoops.bat)
-
- The autoexec.bat file is a special batch file which is usually placed in
- the main or root directory of a disk and automatically executes a series
- of commands (which you have placed there) every time you start the
- computer. In effect, the autoexec.bat file customizes the starting
- sequence of the computer to your liking.
-
- To terminate or stop any batch file in progress (including autoexec.bat)
- issue the break command (control-break OR control-scroll lock).
-
- Let's prepare a batch file:
-
- First make sure you have a formatted disc in your disc drive and DOS
- is operating normally and displays a DOS prompt.
-
- Type following list with a DOS prompt such as a>
-
- Example:
-
- copy con 1.bat (press enter) (cursor skips to new line)
- rem Hello there (press enter)
- ver (press enter)
- date (press enter)
- dir/p (press enter)
- ^Z (press F6 OR hold control AND Z, then press enter)
-
- When done you'll have prepared a batch file of dos commands
- named 1.bat. This small file will print hello there then type the
- DOS version in use then display date and finally produce a directory
- listing and pause after each screenful.
-
- To get the batch file to execute or operate,just type 1 (enter)
-
- Another example:
-
- copy con f.bat (press enter)
- cls (press enter)
- format b:/s (press enter)
- rem all done (press enter)
- ^Z (press F6) then (press enter)
-
-
- This batch file (activated by typing f then enter) will clear
- the screen then prepare to format a blank disc in b: drive - you
- must have the format file on the same disc as this batch file -
- remember that format is an EXTERNAL command. After the batch
- file has formatted the disc it prints "all done" on the screen.
-
- One batch file and start or call another, but the original batch
- file cannot be returned to - you must continue on within the second
- batch file. If a batch file contains a typing or syntax error in any
- of its commands, the computer will stop execution at that point and
- return you to DOS.
-
- Use your imagination and construct batch files to shorten your
- typing tasks. And for a pop quiz, examine the batch file(s)
- on this disc with pc-learn! (hint: use the type command to display
- file contents. example: type 1.bat).
-
- -------------------------------------------------------------------------
- AUTOEXEC.BAT FILE BASICS - THE WAKEUP CALL TO YOUR COMPUTER
- -------------------------------------------------------------------------
-
- The autoexec.bat file starts your computer exactly the way you want.
- It allows you to customize the initial "warmup" as the computer
- comes to life. You can cause the autoexec.bat file to print a
- startup menu of choices, load one particular program, execute
- another batch file and other useful tasks. The autoexec.bat
- file is the FIRST file DOS runs after loading itself and starting the
- computer. The autoexec.bat file must been on the same disc as DOS
- when the computer starts.
-
- An autoexec.bat file can always be modified later, enlarged, edited,
- revised or deleted as you wish. Sometimes it is useful to have several
- autoexec.bat files. Each on a different startup disc to operate different
- programs. An autoexec.bat file (like all bat or batch files) can be
- modified with any ascii (common) word processor. You don't have to
- use the copy con facility each time!
-
- Example:
-
- Prepare this file as you have prepare other batch files seen above.
-
- First make sure you have a formatted disc in your disc drive and DOS
- is operating normally and displays a DOS prompt.
-
- Type following list with a DOS prompt such as a>
-
- copy con autoexec.bat (press enter)
- 123 (press enter)
- ^Z (press F6 OR hold control AND Z, then press enter)
-
- This means (first line) create a file named autoexec.bat as typed from the
- keyboard or con (console). (next line) execute the program named 123. (next
- line) end of my orders from the keyboard - prepare the file and stash it on
- the disc. When finished you'll see a file named autoexec.bat on your
- directory listing screen which contains automatic startup instructions.
- You can also startup the autoexec.bat by typing autoexec and then pressing
- enter. To take a "peek" at the contents of an autoexec.bat file (or any
- bat file) simply use the type command. Example: c>type autoexec.bat
- Example: a>type b:autoexec.bat
-
- Here is another autoexec.bat file, this time from a hard drive startup
- sequence; it provides a higher degree of control and specific
- direction that a computer user might need for hard drive customization
- and more versatle use:
-
- copy con autoexec.bat (press enter)
- path \dos;\reflex;\wp;\util;\doc;\nor;\bat (press enter)
- prompt $P$G (press enter)
- cpu n (press enter)
- verify on (press enter)
- blank (press enter)
- mode bw80,r (press enter)
- dispclk (press enter)
- type menu (press enter)
- ^Z (press F6 OR hold control AND Z, then press enter)
-
-
- Let's examine this more complicated autoexec.bat file in greater detail:
-
- The first line establishes a path command to help DOS search every
- subdirectory on the hard disc (you don't have to switch around to
- different areas of the disc - DOS will search around for you since
- it now know the various "paths" to take.)
-
- The second line alters the cursor prompt to tell you your location
- and subdirectory.
-
- The third line is a reference to the speed the computer will operate at
- and is a unique command to a particular brand of machine (cpu n means
- start the central processing unit chip at normal speed.)
-
- The fourth line turns on the verify function for file copying.
-
- The next line instructs the DOS mode function to switch to black and
- white display, 80 columns wide and shift one colummn to the right for
- alignment.
-
- Next we ask DOS to tell us the time and date.
-
- A final line instructs DOS to type to the screen a file containing
- the menu for this disc.
-
- The ^Z of course ends the file and instructs DOS to store the file
- away for future use on the disc.
-
- Try preparing small (or large) autoexec.bat files and see what they
- do. One clever idea is to store unused files by renaming them temporarily
- (with the DOS ren command) Example: a>ren autoexec.bat auto1.bat. Now you can
- create another autoexect.bat file while leaving the primary file undisturbed.
- You can always go back and rename the primary file autoexec.bat in case
- you have problems and need to retrieve it.
-
-
- end of article, now press escape key to return to menu
-
-