home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
VRAC
/
PCL60A.ZIP
/
PART2.EXE
/
DOSTIPS.TUT
< prev
next >
Wrap
Text File
|
1993-07-13
|
38KB
|
840 lines
The following information is reprinted with permission, Ultimate
Power Tips 1.0A (c) 1992, 1993 Paul Scanlon, Scanlon Enterprises
------------------------------------------------------------
DOS POWER TIPS
------------------------------------------------------------
Getting More Memory From DOS
Would you like more memory for your application(s)? Beginning
with DOS 5.0, Microsoft is allowing users with extended memory
(286 systems and up), to place much of the DOS operating system
into high memory. By adding a couple of lines to your CONFIG.SYS
file, you can have a conventional memory size report from MEM
like this :
655360 bytes total conventional memory
655360 bytes available to MS-DOS
617520 largest executable program size
On a 386 machine, you get even more. Just start your CONFIG.SYS
file with these lines :
DOS=HIGH
device=C:\UTILS\TSR1\himem.sys
Now your application can have over 617K of ram!
Smoother DOS
I have noticed on many client machines, the trend to clump many
files into the ROOT directory of the boot drive (usually C:).
Not only does this slow DOS down, but it could be the potential
for some real problems. On floppies, there is a limit of 112
files for a root directory. This means, that when there are 112
files, DOS will give an error report, of "unable to create file"
on the next attempt to create a file, even temporary files,
which many word processors need. In fact, there are many
applications which create temporary files in the root directory.
If you keep adding files to the root (other than these temporary
ones), then eventually, the application itself will fail! I
suggest, as an experienced consultant, that you create and
maintain several directories, including layered ones.
For instance, ALL DOS programs, should go into a directory
called DOS, just off the root. The only files DOS needs in the
root at boot time, are COMMAND.COM and CONFIG.SYS ! Everything
else, including your mouse drive and ANSI.SYS should be in a
directory. Another directory you should create, is one called
BAT (or BATCH), where you should place all those short batch
files (they don't belong in the root directory). There is only
one batch file which should be in the root, and that is
AUTOEXEC.BAT!
What of layered directories ? If like me, you collect utilities,
then you should keep those most often used in one directory and
the rest in another, and NOT in the root directory! A layered
directory is one which is inside another. For instance, on my
machine, I created a directory called UTILS, which itself,
contains only other directory names. Inside UTILS, I created
directories with names of L1, L2, L3, etc... and each one has
utilities, which are of lesser and lesser importance, with L1
containing the most often used.
Why this struggle to remove files from the root and use of
layered directories? Because, DOS must search for whatever you
type at a DOS prompt, or what is requested from a batch file.
DOS will search a 10 entry directory faster than a 100 entry
directory! You WILL notice this extra speed! The layered
directories adds to this approach. When you made your AUTOEXEC
batch file, you added a line starting with "PATH=", which
contains the search string for DOS. This search string tells DOS
where to begin looking for executable programs, after checking
the current directory. For this reason, I place my DOS directory
as the first search entry like this : PATH=C:\DOS
If all of your executables were in this one directory, that
would be all you needed! This would be the case for small hard
drives, such as the old 10MB and 20MB drives. This is NOT the
case for systems with dozens of applications, which can be
executed from any DOS prompt. In my case, for example, I created
the extra utility directories inside a main directory called
UTILS, with the names of L1, L2, L3, etc.. In this case, my PATH
statement, in my AUTOEXEC has the following PATH statement:
PATH=C:\DOS;C:\UTILS\L1;C:\UTILS\L2;C:\UTILS\L3
We prefix the path, with a drive letter, because, we might be on
drive A or B when we request a utility or DOS function. Notice
the semicolon between entries. DOS requires these to delimit one
path entry from another. A well designed hard drive, will have
less than 20 entries in the root directory!
Easy Disk Transfer
Add the following two batch files to your system to make copying
files from drive A to your hard drive easy. The batch file
TOA.BAT copies selected (or all) files to drive A, while the
batch file FROMA.BAT copies selected (or all) files from drive
A. By using these two batch files, you can avoid have to retype
and retype the DOS COPY command.
TOA.BAT
REM ------------------
REM - TOA.BAT -
REM ------------------
REM Copy several files to drive A:
ECHO OFF
IF NOT %1* == * GOTO LPB
COPY *.* A:
:LPA
SHIFT
:LPB
IF %1* == * GOTO XIT
COPY %1 A:
GOTO LPA
:XIT
REM End of batch file
FROMA.BAT
REM -------------------
REM - FROMA.BAT -
REM -------------------
REM Copy several files from drive A:
ECHO OFF
IF NOT %1* == * GOTO LPB
COPY A:*.*
:LPA
SHIFT
:LPB
IF %1* == * GOTO XIT
COPY A:%1
GOTO LPA
:XIT
REM End of batch file
Now, if you want to copy, for example, 3 files to drive A:,
called MYF1, MYF2 & MYF3 you simply enter :
TOA MYF1 MYF2 MYF3
If the same files were on A: and you wanted them on C: you'd
enter this :
FROMA MYF1 MYF2 MYF3
These batch files examples can easily be modified to include
other drives, such as B: or D: !
Batch File, Know Thy Self
Do you have a batch file which must be run on drive A: only,
such as an INSTALL.BAT file? Add these few lines to your batch
file, and it will know if it is running on drive A: (Assume the
batch file name is INSTALL.BAT).
IF NOT %0 == A:INSTALL.BAT GOTO DRVERR
{Your batch file commands}
GOTO XIT
:DRVERR
ECHO You must start this batch file from drive A:
:XIT
DOS sets batch file %0 equal to the path (including drive) and
file name of the current running batch file.
The Invisible DOS TYPE Command
DOS has several built in commands, one of which is the COPY
command. This is normally used, to transfer files from one disk
to another. This remarkable utility can also, display or print a
file. To print a file, simply use the following:
COPY filename PRN
Where "filename" is any valid DOS file name, which may include
drive and path. Alternately, you may substitute LPTn for PRN,
where "n" is in the range of 1 - 4 on PC compatible machines and
1 - 9 on PS/2 compatible machines. To display a file, simply
enter the following :
COPY filename CON
Where "filename" is the same as above. You will have to be quick
to stop the scrolling, as it will scroll off screen, if you do
NOT use the PAUSE key to halt it. The advantage of using this
approach for printing, is that the DOS redirector ">" does NOT
have to be used, as when using the TYPE command, IE.. TYPE
filename > PRN . Another advantage of using COPY, is that if you
are on a strange machine, and it doesn't have TYPE.COM anywhere
around, then you can use COPY as it's a built in DOS function,
and does NOT require an external program to execute.
Use Your Computer as a Typewriter
To type directly from the keyboard to a printer, a quick yet
easy way is to use "COPY CON PRN". This is entered directly from
a DOS prompt. You won't have word wrap, or other wordprocessor
features, but you can correct any text entered on the current
line. You simply enter a line of text, and press {Enter} after
assuring that the line is correct. Once entered the last line to
send to the printer, hold the Control key down and press the "Z"
key. Release both keys and press {Enter}. Everything that you
have typed will be printed on your printer.
Protecting System Files From Accidental Deletion
You're working in an application directory on your hard disk
with a job running longer than expected. So you decide to make
room on a recycled floppy to copy files and finish the project
at home. You type "DIR A:" and see that you no longer need the
data on the floppy disk, but then you type "DEL *.*", and when
DOS asks "Are You Sure (Y/N) ?", you answer "Y", erasing all the
files in your application directory! Protect yourself from this
type of accidental erasure, by using the DOS command "ATTRIB +R
*.*" to make all files in your applications directory read-only.
You can un-protect individual files that require regular
updating (personal dictionaries and so on) by typing "ATTRIB -R
filename".
Easy On-Line Reminders
If you can't always remember short but complex procedures and
command sequences (printer setup codes and the like), jog your
memory with brief, on-line ASCII how-to files created with your
text editor or word processor. Format the files so that they're
easily readable in a single screen. Give them names you'll have
no trouble remembering, and store them in a directory call
"\HELP". Then add a batch file called "HELP.BAT", which contains
the line "TYPE \HELP\%1", to your batch file directory, which is
contained in the PATH statement, of your AUTOEXEC.BAT file. When
you need assistance, use the DOS command "HELP filename" to get
an instant refresher course.
Determining Your Rom Bios Date
If you are experiencing problems with a hardware upgrade, you
can use the DEBUG utility (which came on one of your DOS disks)
to check the date of your computer's Rom Bios. Run DEBUG, and at
the hyphen "-" prompt type DFFFF:5 L8 and press {Enter}. Your
system's Rom Bios Date will appear on the right side of your
screen. Press Q then {Enter} to return to a DOS prompt.
A Quicker Exit
If you frequently shell out of applications or an environment,
you probably get plenty of practice typing "EXIT" and pressing
{Enter} to return to the application. You can save yourself some
keystrokes by creating a batch file called E.BAT that contains
the line "EXIT". This batch file should be in a directory listed
in the PATH of your system.
The Shell in the Shell
If the WordPerfect Library shell loads inside of itself, you DOS
prompt will read something like "(SHELL)(SHELL)C::>", and {F7}
won't bring back the Library screen. To solve the problem, type
EXIT and press {Enter}, then press {F7} at the Library screen,
repeating the process until your prompt has only one "(SHELL)".
To avoid the problem, regularly use {F7} rather than the SHELL
command to return to the Library.
Where's That Ram
More and more VGA Boards are sporting 512K or more of Ram. But
if you check video RAM with the current version of most programs
like Chekit, System Sleuth or Norton Utils, they show up to 256K
only. Not to worry, the additional Ram is really there, but the
BIOS calls (standard) do not yet support for video ram sizes
greater than 256K.
DOS FILES and BUFFERS CONFIG.SYS commands
The CONFIG.SYS file, MUST be located in the ROOT directory of
the boot drive. This file, contains commands to set some DOS
resources plus installation of Device Drivers, such as that for
the Mouse. By default, DOS reserves small portions of memory to
use, to track and manage a number of disk drives, open files,
standard devices such as the video and keyboard, and disk data
buffers. The FILES command lets you increase the maximum number
of simultaneously open files, a necessity of modern applications
that open multiple data, index or internal utility (such as a
spelling checker) files. In DOS versions prior to 3.3, FILES
could NOT be set greater than 20! With newer DOS versions, we
can now set FILES to as high as 255! BUFFERS, is a command to
enable a selected number of disk buffers, DOS's built in disk
cache system. The larger the number of Buffers, the more disk
cache available to DOS, and the less memory available to your
application program. The ideal setting for FILES, depends on the
applications you are running. Many applications, upon
installation, modify the CONFIG.SYS file to make FILES the
correct size for that application. Other applications, simply
warn the user to have FILES set to the correct value. Find the
application requesting the largest number of FILES and set FILES
to that number, plus 2, for each TSR you may have, which access
files. IE.. your word processor wants 20, and you have 3 TSR
programs running that access files, then set FILES=26 in your
CONFIG.SYS file. If you are running DOS versions prior to 3.3,
there are some Shareware utilities which can set the max FILES
to larger than the DOS limit of 20! The BUFFERS command sets up
the DOS internal buffers, which hold copies of recent disk I/O.
Whenever an application wants to read or write data to a disk,
DOS first checks the disk buffers to see if the requested data
is there. If the data is, then disk I/O is NOT necessary. This
speeds up your application. Of course, having too many BUFFERS
can slow things down, as this would mean more searching. The
optimum number of BUFFERS depends in part upon the
characteristics and types of drives on you system, the
application types and number of directories and sub-
directories. For example, having a large number of buffers does
NOT improve performance of applications that access files
sequentially, but can dramatically reduce the execution time of
programs that access files randomly, especially files with small
record sizes, such as an index file. Increasing BUFFERS is also
useful for systems with layered directories (several layers). If
you are, however, using a disk cache system, then you should set
BUFFERS=1 (see your cache system manual).
ATTRIB to the Rescue!
You can find files with the DOS ATTRIB command just as easily as
using the program WHEREIS! Simply enter "ATTRIB *.TXT /S" will
find all TXT extension files, listing them to the display. Want
a listing ? Then use "ATTRIB *.TXT /S>TXT.LST" will put the
listing into the file "TXT.LST".
Another useful use of ATTRIB, is to force programs which will
not accept will cards, to perform their task over a range of
several files, without having to enter each one manually. We can
do this across directories. First, we must set the archive bit
on all files we want to perform a task on. Do this with the
command "ATTRIB +A *.TXT /S". Next, rename the program that you
want to operate on all the selected files, in our example, we
will use POWER.COM, to A.extension (our example is A.COM). Now,
use attrib to make a batch file, like so, "ATTRIB *.TXT
/S>OPT.BAT". The batch file thus created, will contain a list of
each TXT extension file, preceded by A, such as "A
C:\MYTXT.TXT". Now executing the batch file will cause our
program POWER.COM, renamed to A.COM, to operate on all TXT
extension files!
A Different DOS Backup System, for FREE
You can use the DOS ATTRIB and XCOPY to make a very powerful
back up system. The DOS BACKUP command, is know as having many
bugs and restore problems, especially if restoring between DOS
versions. To back up your system for the first time, use the
following ATTRIB command line.
ATTRIB +A *.* /S
This will SET all file archive flags, in all directories of the
current drive. We can now begin the backing up all files. First,
have a stack of formatted disks ready for you backup. For 40
megabytes of data, you will need; 110 360K disks, 33 1.2Meg
disks, 55 720K disks or 28 1.44meg disks. Now, at your DOS
prompt, enter the following command line.
XCOPY *.* A: /A /S /E
This will fill the first disk and exit with a "Disk Full"
message. Simply ignore the error, and replace the full disk,
with an empty one, press the [F3] key to duplicate the previous
command (or retype it), and repeat this process, until there are
no files to copy. After making this initial set, you will only
need to back up new or modified files. Doing this, simply
requires you to have enough formatted disk ready to copy the new
data (usually one disk is enough). Now type the line beginning
with "XCOPY" from above, and all NEW files will be cloned on
your disk. Using this process, also makes the directories on the
floppy as it goes, including empty ones. The only draw back to
this method, is attempting to back up files larger than the
selected disk size. IE... a 360K disk will only hold a file up
to 360K in size.
Stop Struggling With The DOS Format Command
Do you often format different density disks in the same drive?
Here is a quick batch file, which will save you keystrokes.
@ECHO OFF
REM FORMAT.BAT
REM RENAME THE DOS FORMAT.COM TO FORMAT!.COM
GOTO %1
:HELP
ECHO You must specify the type of disk you want to format
ECHO FORMAT 360 will format a 360K disk in drive A:
ECHO FORMAT 12 will format a 1.2MB disk in drive A:
ECHO FORMAT 720 will format a 720K disk in drive B:
ECHO FORMAT 144 will format a 1.44MB disk in drive B:
ECHO Do NOT include the drive letter
ECHO Other FORMAT options are OK
GOTO DONE
:360
FORMAT! A: /N:09 /T:40 %2 %3 %4
GOTO DONE
:12
FORMAT! A: /N:15 /T:80 %2 %3 %4
GOTO DONE
:720
FORMAT! B: /N:09 /T:80 %2 %3 %4
GOTO DONE
:144
FORMAT! B: /N:15 /T:80 %2 %3 %4
GOTO DONE
:DONE
If your drives are different that the above, simply edit the
lines, to the correct drive letter. Remember, 5¼ inch drives are
360K and 1.2MB while 3½ inch drives are 720K and 1.44MB. Thus,
if your drive A: is 3½ instead of B:, then simply change the
above A:'s to B:'s and B:'s to A:'s !
FREE File Viewer From DOS
If you want a FREE file viewing utility, you have one already!
Many of you already are aware of using the good old line of
TYPE filename | MORE
Save your self some typing and create the following one line
batch file calling it TYP.BAT
MORE < %1
This results in the same output as the earlier one using the DOS
command TYPE! The %1 will be replaced at execution time, by the
specified file name, such as TYP MYFILE ! Of course, this
feature does NOT support paging or scrolling features found in
many good FileListing utilities. However, if you're just
interested in viewing a file to see if it's worth keeping or
printing this is fast and easy to use. To abort the scrolling,
simply press <Ctrl>C or <Ctrl><Break>! To move from to the next
video page, press any key!
A No Text Editor Method of Creating Short Batch Files
Need to create a one line or short batch file? You don't even
need to start your text editor or word processor. At a DOS
prompt, enter the following single line:
COPY CON filename
Replace "filename", with the name of the file you want to
create. Press <ENTER> after "filename". The cursor will be
located to the next line, and you begin entering keystrokes just
as though you were using a text editor. You will NOT be able to
edit a previous line (you can't cursor up). Once you are though,
all text lines entered, press <F6> <ENTER>. You will get a DOS
prompt back.
More Ram For Your Applications
Here's a way to save 1K or more of application ram, if you are
loading TSR's into ram from your AUTOEXEC batch file. The trick,
is to arrange you startup commands efficiently. Put DOS commands
that don't increase the size of the environment, such as CHKDSK,
ECHO and BREAK at the beginning of AUTOEXEC. Now load your TSR
applications, making sure to include the path names. This is
done prior to setting the path or other environ variables such
as COMSPEC. After loading your TSR's you can execute any command
which will increase the environ size, such as PATH and PROMPT.
The reason we can gain memory in this manner, is because each
time an application is loaded, DOS gives the application a COPY
of the ENVIRON area, which includes PATH settings, etc... If we
start our TSR's prior to setting any ENVIRON variables, we will
give a TSR a smaller ENVIRON area! In this way, if your ENVIRON
space uses 200 bytes and you have 5 TSR applications you'll save
1K byte!
FOR POWER!
The DOS batch command FOR, can invoke several commands on a
single line, to speed up your batch files. Consider an AUTOEXEC
batch file that has the following 3 lines.
PROMPT=$P$G
TSR1
TSR2
DOS must access the disk 3 times to read those 3 commands.
Instead, pack all 3 commands into 1 line, using FOR :
FOR %%F IN (PROMPT=$P$G TSR1 TSR2) DO %%F
This single line batch command replaces the previous 3 lines! In
this case, the FOR command takes each entry (space delimited)
and substitutes them for the variable %%F. In this way, DOS will
only need to access the disk 1 time to read the 3 commands,
instead of the previous 3 times! The one restriction with this
tip is that programs executed in this fashion, can NOT have an
argument passed to them. Also, the FOR command interprets
semicolons as delimiters, just as it does spaces, so, you can
NOT include your PATH command in a FOR command.
Batch Files That Count
Use this counting routine in batch files to perform routine
tasks, such as backups, that you want to execute at regular
intervals. The batch file COUNT.BAT, for example, used in your
AUTOEXEC.BAT file, will automatically run CHKDSK /F command
every third time you reboot. COUNT.BAT creates a zero byte file
and uses its name as the counter. Create the batch file,
COUNT.BAT, then add the line CALL COUNT.BAT to your AUTOEXEC.BAT
file.
ECHO OFF
CLS
IF NOT EXIST BOOT? GOTO NO
FOR %%F IN (BOOT3 BOOT2 BOOT1) DO IF EXIST %%F GOTO %%F
GOTO ERROR
:NO
TYPE >BOOT2
GOTO END
:BOOT3
REN BOOT3 BOOT1
CHKDSK /F
GOTO END
:BOOT2
REN BOOT2 BOOT3
GOTO END
:BOOT1
REN BOOT1 BOOT2
GOTO END
:ERROR
ECHO A BOOT file already exists, please delete
ECHO it and retry.
:END
When you execute COUNT.BAT, it checks for a file named BOOT? and
branches to a label in the batch file, although most of the
branching simply renames the BOOT? file to the next level, thus
incrementing the counter. In the first pass, the BOOT2 file is
created via the instructions at label NO. We make an initial
file of BOOT2 because this will have been the first pass. Each
additional pass thru the batch file, causes a high numbered
BOOT? file to be created, by renaming a previous level. If
during the first pass, a BOOT? file is discovered, other than
the 3 BOOT? files we want, we branch to the ERROR label and
instruct the user to delete it. You can perform tests on as many
different branches as you wish. For example, you might count to
10, running CHKDSK /F on count 5 and a back up on count 10. Just
add additional BOOT? names in the line beginning with FOR, and
additional labels after BOOT3 for the additional BOOT?
functions. NOTE, the COUNT.BAT file is in the root directory
with AUTOEXEC.BAT and BOOT? files.
DOS 5.0 CHKDSK Meanings
Many users are confused by the DOS 5.0 CHKDSK display. The
following is a DOS 5.0 CHKDSK report for a PC with a 40MB hard
drive, along with the meaning.
33462272 bytes total disk space
57344 bytes in 5 hidden files ────────┤ Hard disk space
172032 bytes in 74 directories │ utilization in
29212672 bytes in 4921 user files │ bytes
3975168 bytes available on disk
│ Disk space allocation
│ units. An allocation
│ unit is a group of
2048 bytes in each allocation unit ─────┤ sectors that DOS
16339 total allocation units on dis │ treats as a single
1941 available allocation units on disk │ block. It represents
│ the least amount of
│ disk space DOS will
│ allocate to a file.
│ Amount of convention-
655360 total bytes memory ──────────────┤ al memory installed
511984 bytes free │ and available. This
│ memory is different
│ from hard disk memory
│ reported above.
Allocation units are also called CLUSTERS.
A hard drive is much like a floppy disk, except it can hold much
more data, and can NOT be removed like a floppy. In addition, a
hard is accessed faster than a floppy. RAM, is temporary
storage, inside the computer, and goes away each time power is
turned off, and must be restored each time your computer is
turned back on. This process is called booting.
Emergency Disks
If you are backing up your system regularly, the following
information will aid in getting you back up and running quickly.
You will need to make a DOS boot disk (if you have an older
machine it will be a 360K disk). To make a boot disk, place a
new (un-formatted) disk, into drive A: and type "FORMAT A: /S"
at your DOS prompt. This will create a bootable disk, with the
DOS operating system on it. Now, put the following DOS utilities
on this disk :
FDISK.EXE
FORMAT.COM
DEBUG.COM (XT machines only)
If the disk has room, place a copy of your backup program onto
the disk (or just the restore portion). If your backup program
will NOT fit onto this disk, then you will have to put it onto a
separate disk. You might read your back up disk documentation to
see if it suggests how to make an emergency restoral disk. Next,
you will need a low level formatting program, such as Disk
Manager, or for XT machines, you will need to place the DOS
DEBUG.COM program on the emergency disk. Mark the disk(s),
"Emergency Boot Disk(s)". Now, when your hard drive fails (all
eventually do), you'll be able to restore the system. Simply
repair or replace the hard drive, pull out your back up disks
from your last backup and do the following.
1) Boot your system from the "Emergency Boot Disk"
2) Start the lowlevel formatting program
3) Run FDISK to partition the drive
4) Run Format to format the drive
5) Run your backup programs restore file option
If you are restoring an XT, then replace step two above with :
2) Start DEBUG, and enter GC800:5 at the "-" prompt
This will lowlevel format an XT machine.
If you backup regularly, getting things going will be much
faster and easier than with out regular backups. If you are
attempting to restore you system without a backup set, you'll
have to have original disks for each application and reinstall
each! If you had data, on the broken drive, which must be
recovered, you'll have to lay out a big chunk of money to a data
recovery service to get the data off the broken drive (and there
are NO guarantees the data can all be recovered). By backing up
regularly, you need only perform the above 5 steps, with a time
of around 2 hours to several hours. If you don't, it may take
you months to recover the data you lost!
Directory Navigation Shortcuts
Save yourself time and keystrokes, by using these directory
navigation shortcuts.
If you are in a directory \WP\FILES and wish to go to \WP\DOCS
you'd type these lines.
CD \
CD WP
CD DOCS
These three lines can be replaced with one:
CD ..\DOCS
DOS supplies us with a directory entry "..", which references
the previous directory level. By Type "CD .." we go back one
level. By adding the "\DOCS" to the tail of this string, we can
navigate the entire change in one command. First, DOS moves back
the one level (now in \WP), then DOS moves forward one level to
the directory DOCS (now in \WP\DOCS).
Another interesting aspect of this function is in navigating
multi-level directories. If you are in the following directory :
\WORD\FILES\LETTERS\APRIL
And wanted to go to the directory \WORD\FILES, you'd normally
type two lines :
CD \
CD WORD\FILES
Or even the single line "CD \WORD\FILES" to combine the two
commands into one. There is a shorter way, simply type the
following : CD ..\.. You're there !
Batch File CALLS Using DOS Before Version 3.3
In DOS 3.3 and up, there is a new command "CALL", which will
execute another batch file, then return to the original batch
file, starting at the line after the "CALL". For instance :
ECHO OFF
CLS
CALL AUTO
MENU
Would call the batch file "AUTO", then return an start a MENU.
This function can be emulated using earlier DOS versions, and
without executing another COMMAND.COM shell! To do this involves
a little forethought and planning. Taking the above example, we
create a batch file, adding a couple of lines.
ECHO OFF
IF %RETURN%*==* GOTO START
GOTO %RETURN%
:START
CLS
SET RETURN=RETURN
AUTO AUTOEXEC
:RETURN
MENU
After our ECHO OFF (halt echoing), we check to see if the
variable (DOS Environ) is set, and if so we assume it is set to
a label in the current batch file, AUTOEXEC. If there is NOT a
label, we branch to the normal entry and clear the display.
However, if RETURN has a value, we branch to that label,
assuming the label is in the current batch file AUTOEXEC. After
clearing the screen, we set our return label to RETURN and start
the AUTO batch file.
The batch file AUTO will then have these lines:
{your batch file commands}
%1%
The last line, returns control to the original batch file. The
AUTOEXEC after AUTO in our first batch file, is will replace the
%1 parameter ! When we return, we will automatically return to
the label "RETURN" in the first batch file, then we can start
the menu.
Nested Batch Files Save Time
If you want to beef up your batch files, use the DOS COMMAND /C
and CALL commands, to create nested batch files that call up one
batch file from within another. Without these commands, an
executing batch file that summons another will execute the
second file and return to a DOS prompt, without completing the
original batch file. With DOS 3.3 and higher, CALL, an internal
command, can be used to invoke a second batch file, like this :
DATE
CALL TELECOM
WP
In this example, which loads a communications program, then a
wordprocessor, the CALL command invokes the TELECOM batch file
and returns control to the original batch file, which then
executes the WP command. If you are using DOS earlier than 3.3,
then a different method must be used. The following batch
example will perform as the above, for DOS versions earlier than
3.3 :
DATE
COMMAND /C TELECOM
WP
This approach does have disadvantages. Unlike the DOS 3.3+ call
command, COMMAND /C loads another copy of COMMAND.COM to execute
the second batch file. When COMMAND.COM terminates, it passes
control back to the first batch file, which then executes the
final instruction WP. Because each nested batch file has it's
own copy of COMMAND.COM , memory usage will be high, and the
number of nested calls will be much less than later DOS versions
with the CALL command. You can use the CALL and COMMAND /C
approach, even from an AUTOEXEC batch file.
Tutorial finished. Have you registered PC-Learn to receive your
bonus disks? Registration is encouraged. Shareware works on the
honor system! Send $25 to Seattle Scientific Photography,
Department PCL6, PO Box 1506, Mercer Island, WA 98040. Latest
version of PC-Learn and two bonus disks shipped promptly!