Ref: 11420008
Title: How to Work Around the DOS "Out of Environment Space" Message
date: 12/14/89

Copyright 3Com Corporation, 1991.  All rights reserved.

Whenever a DOS program is run, the system calls up a command
processor (such as COMMAND.COM) to handle it.  The type of
command processor, and the amount of memory it has to work in,
are specified in a DOS environment, which is created each time
DOS boots.

Along with the command processor, the DOS environment stores
other information, such as a system prompt and a path to search
for files, to ensure a user will have a consistent-looking
interface to the operating system whenever he or she logs in.
Because the DOS environment is a special file (defined only as
"a location in memory"), its contents can only be displayed or
changed using the SET command.

By default, DOS allocates 127 bytes for environment strings.  If
you have not installed any resident programs or code, DOS will
allocate additional space for the environment as required.  However,
when you run 3+Menus or another resident program, DOS loads a
new command processor.  And, before the new command processor is
loaded, DOS puts a limit (equal to the bytes used by the strings
in the environment) on the amount of environment space.  Thus,
if you run a program from within a batch file or from 3+Menus, you
may run out of environment space and see the message "Out of
environment space."

This message may also occur when your workstation boots the
CONFIG.SYS and AUTOEXEC.BAT files.  Any PROMPT, PATH, or SET
commands contained in those files define your environment space.

To investigate the problem, check the batch file that loads the
application from 3+Menus.  The batch file probably contains other
SET commands or a long path statement.  But because the user's
environment space is already filled, it cannot load the other SET
variables into itself.

To solve the problem, fill the original environment space
with extra characters, then clear them from the batch file that
loads new PATHs, PROMPTs, or SET commands.

For example, suppose that the original environment space is
100 bytes in size, but the statements within the environment only
consume 50 bytes.  When a new command processor is loaded it
will receive a copy of the 50-byte environment.  To reserve the
50 unused bytes from the original environment space, do the
following:

1.  At a DOS prompt, type SET z=zzzzzzzzzz.  (For "z," substitute
any unused character.)  Continue typing z's until you hear a beep.
This means that all previously unallocated space within the DOS
environment has now been filled with z's.

2.  If you want, type SET to look at the contents of the DOS
environment.  You will see all of the strings, including the line
of z's, that were added to the environment with the SET command.

3.  Locate the batch file that loads the desired application.
(The batch file's owner, who may be the network administrator,
will know where the batch file is.)  In the batch file, insert
the command  SET z=z

Now, when the batch file loads the new shell, it will copy all
100 bytes (50 bytes of the original environment plus the other
50 bytes of z's) to the new environment space.  Before the
environment is set, the batch file reads the SET z=z command
and clears from the environment space all of the z's except one.
The new environment space then contains 50 bytes from the original
shell plus 1 byte from the new shell, leaving a total of 49 bytes of
free space to enter new SET commands.

