Ref: 09330001
Title: Out of Environment Space
Date: 7-15-88

Copyright 3Com Corporation, 1991.  All rights reserved.

We have been encountering the DOS error "Out of Environment
Space" lately when installing 1.1 on a 3Server(3).  This error
message will appear on the screen of the PC you are using to run
3Console.

The environment space is a number of bytes set aside by DOS for
SET commands, e.g., the PATH statement.  The 3+ installation
menus also use this space to store variables.  If you install
many services at once, the menus employ many variables, and you
run out of environment space.

The solution is to install as many services as you can before you
get the error.  Before installing any more services reboot the
server.  This will clear out of the environment space all the
variables used by the other installation menus.

-----------------------------------------------------------------

The following is an excerpt from another message that is relevant to this
article.

I've found an undocumented bug in the way DOS handles its environment
space that may occasionally cause problems for 3+ or other batch files.

.h2;Summary
Problem:  A customer running a batch file, such as one of the 3+ installation
batch files, encounters the DOS error message "Out of environment
space".  The message may not remain on the screen, and the batch file
does not necessarily stop running.  Other DOS error messages such as
"Bad command or file name" or "Syntax error" may subsequently appear,
and the batch file does not produce the expected results.

Solutions: If you're using the DOS option of an application program, such
as F5 in Menus or [Ctrl]+D in Mail 1.3, quit the application program before
running the batch file.

If you're not sure whether you're using the DOS option of another
program, type EXIT at the DOS prompt.  You'll return to the application
program if there was one.

If running directly from DOS doesn't work or isn't the problem, use a
text editor to insert one of the following lines in the CONFIG.SYS file
of the PC's boot disk:

     shell = command.com /e:20 /p        for DOS 3.1
     shell = command.com /e:320 /p       for DOS 3.2 or higher.

Then reboot the PC and try again.

.h2;Technical Discussion
DOS stores information about the COMSPEC, PATH, and PROMPT in an area
called the environment space.  Users can also write to this space by
setting variable values using the SET variable=value command.  You can
see the contents of your environment by typing SET [Return].

Batch files often make extensive use of the SET command, and test the
values of environment variables using the IF function to determine where
to branch to.

By default, DOS allocates 160 bytes to the environment space.  DOS can
expand this allocation dynamically if necessary; supposedly the
environment can expand indefinitely if no TSR (terminate-and-stay-
resident) programs have been loaded but not at all otherwise.  In fact
there does seem to be some room for expansion even with TSR programs,
and some limits on environment size even without them.

When any program, including a secondary command processor (such as the
one loaded by F5 in Menus or [Ctrl]+D in Mail) is loaded, it gets a
copy of the contents of the primary environment.  However, it does not
get a copy of the free space allocated to the environment; most of
the time it gets only 15 to 30 bytes free.  Therefore, running a batch file
that writes to a secondary environment may produce the "Out of
environment space" message no matter how big the primary environment
is.  If there's a CLS command in the batch file it will clear the
message, but because variables have not been set properly other error
messages will probably appear later.  Exiting the secondary
COMMAND.COM and quitting the application program solves this problem.

If it's the primary environment that's too small--probably because of a
long PATH command--the SHELL command can be used to expand it.  In DOS
3.2 or higher the /e: parameter sets the number of bytes allocated to
the environment.  In DOS 3.1 the /e: parameter sets the number of
paragraphs (where a paragraph is 16 bytes); this 3.1 command is also
undocumented.  (The /p tells DOS that this is a primary command
processor, and after it's loaded it should look for AUTOEXEC.BAT.)

As a temporary measure, you can also use the SET command to clear
unneeded variables (using SET variable= without a value), and then reset
them later.

The MAKEDISK program written for 3Server3 Complete and 3S/200 does
abort if it runs out of environment space, and it displays an error
message with some of this information.  Version 1.2.2 will also suggest
quitting your application program.

To determine exactly how many services you can install, you would have
to compare the size of the environment with the length of any preset
variables, such as the PATH, PROMPT, or COMSPEC, and the length of
variables set by the batch file.  Count the characters in the variable
name, its value, the equals sign, one null byte to mark the end of each
string, and an extra null byte to mark the end of the environment.
