home *** CD-ROM | disk | FTP | other *** search
- Taking Advantage of Your PC's Hard Disk:
- Part II, DOS BATch Files
-
- Barry Gordon
- New York Personal Computer, Inc.
-
- DOS and BATch Files
-
- Familiarity with DOS is assumed. However, it is helpful to the
- new user to include a paragraph or two on BATch files. The IBM
- PC and DOS work with three different kinds of program or command
- files: .EXE, .COM, and .BAT files. (BASIC and BASICA work with
- their own .BAS files, but those are not relevant to the present
- discussion.) The .EXE and .COM files give instructions to the PC
- itself. They are produced by assemblers, compilers, and linkers.
- The .BAT or BATch files are instructions to DOS which you create
- for your own convenience. I will discuss a couple of commands
- that you may find convenient in working on your PC: the DOS
- PROMPT command and the PATH command.
-
- The DOS PROMPT Command
-
- Just as DOS keeps track of a default disk drive, it will also
- keep track of each drive's current directory (the directory you
- are working in). Most often, this directory is the one you tell
- DOS to assume and use when no other is specified. The DOS prompt
- always has indicated the default disk drive followed by the
- greater-than symbol: A> which works well for diskette drives.
- With a hard disk, you will want to know the directory you are
- working in (the current directory) as well. You can customize
- the prompt to show the current directory using the DOS PROMPT
- command. The command PROMPT $P$G tells DOS to display the name
- of the current directory whenever the prompt appears on your
- screen. Other, more elaborate, prompt variations are possible,
- but $P$G is a useful beginning.
-
- The DOS PATH Command
-
- The actual program fetching is accomplished by means of the DOS
- PATH command. This command tells DOS where to look for your
- programs (the executable files) when they are not in the current
- directory. The overall scheme begins to take shape: you work in
- the (current) directory containing your data files, and DOS looks
- for the programs you need (in priority sequence) in other sub-
- directories. Thus, your PATH command might look something like
- this:
-
- PATH C:\anyname1;C:\anyname2;C:\any3
-
- The PATH command should contain the full specification of each
- sub-directory, including the drive designation. This keeps the
- search path valid even if you should decide to make, say, drive
- A: the default drive temporarily.
- Since the root directory is not named, it is not included in the
- PATH command.
-
- Of course, having to enter all of this PROMPT and PATH
- information each time you turn on your PC can become a nuisance.
- The proper way to handle this is to create special BATch files in
- the root directory that store and execute your commands.
-
- Creating BATch Files
-
- The most direct way to create .BAT files is to use the DOS
- ability to COPY a file directly from the PC keyboard into a disk
- file:
-
- COPY CON filename.BAT
-
- where CON is the DOS name for the keyboard, and "filename"
- represents the name you wish to give your new BATch file. You
- enter your file contents, line by line, ending with a line
- containing ^Z (Control-Z), which can be entered by pressing the
- Function Key 6 (F6). As an alternative (though I don't recommend
- it) you could learn to use EDLIN, a minimal file editor, whose
- chief virtue is its automatic inclusion with the DOS package.
- For serious work of this kind, a good file editor is a great
- help. The IBM Personal Editor is one of the very best.
-
- The AUTOEXEC and SETPATH BATch Files
-
- The AUTOEXEC.BAT file is executed only at startup (unless you
- specifically enter it), and contains those commands you wish to
- enter for your convenience in operating your PC.
-
- A simple version of an AUTOEXEC.BAT file might look like this:
-
- DATE
- TIME
- PROMPT $P$G
- PATH C:\anyname1;C:\anyname2;C:\any3
-
- The first thing you may want to do is to move the PATH command
- from the AUTOEXEC.BAT file and put it in its own BATch file
- called SETPATH.BAT. The AUTOEXEC.BAT would have these four lines:
-
- DATE
- TIME
- PROMPT $P$G
- SETPATH
-
- Your SETPATH.BAT file would look like this:
-
- PATH C:\anyname1;C:\anyname2;C:\any3
-
- Putting the PATH command in the SETPATH.BAT file lets you modify
- your program search path any time you wish, and then restore it
- by getting into the root directory and entering the SETPATH
- command.
-
- ath any time you wish, and then restore it
- by getting i