[net.micro.pc] MS-DOS Environment Size

fulton@comet.DEC (Cathy Fulton, CXO Technical Training) (02/13/86)

Over the last six weeks or so I have seen several questions on both usenet
and ARPANET about DOS environment size.  This subject was very important to 
me, as I run MANY different applications under MS-DOS which require much use
of SET and PATH in autoexec.bat.  I frequently had to play games in order to
pare my environment size down to the default 160 bytes.

Well, thanks to the Feb 26, 1986 edition of PC Magazine, I no longer have
to worry about receiving the "Out of environment space" error message.  Here is
the info I was so glad to get:

   "...PC-DOS 3.1 does have a way to enlarge the environment.  What you must
   do is use a CONFIG.SYS file to specify COMMAND.COM as a SHELL.  This is done
   with a line in the CONFIG.SYS file that reads

      SHELL=COMMAND.COM /P /E:62

   Without the /P parameter, COMMAND.COM would not execute the AUTOEXEC.BAT
   file.  (This is something that goes back to DOS 2.0.)  The /E parameter is
   new with Version 3.1.  The value following the colon is the number of 16-byte
   paragraphs reserved for the environment.  The default is 10 paragraphs
   (160 bytes) and the maximum is 62 (992 bytes). (If you set the value below 10
   or above 62, COMMAND.COM will use the default of 10.)..."

As noted above, this only works with DOS 3.1.  If you are running version 2.x
and want to upgrade to 3.1:

   "...boot up the machine with the 3.1 DOS diskette in drive A:, run the SYS
   command [ex.- "SYS C:"], copy over COMMAND.COM, and copy all the other DOS
   files..."

I successfully accomplished both of the above tasks (MS-DOS 2.1 to 3.1, and
increase of environment size to 992 bytes) today on my Zenith Z-151.


...decvax!decwrl!dec-rhea!dec-comet!fulton
fulton%comet.DEC@decwrl

jrv@siemens.UUCP (02/17/86)

For anyone who has not updated to DOS 3.1 and has run out of environment
space here is a patch to DOS 2.x COMMAND.COM which allows you to allocate
more than the default 10 paragraphs.

Run debug on command.com (It would be advisable to do this on a
duplicate copy in case something goes wrong with the patch.):

	c:> debug command.com <CR>

The allocation of memory for the operating systems copy of the environment
is hard coded as:

               Assembly Code       Hex Values
xxxx:0ece	MOV BX,000A	    BB 0A 00
xxxx:0ed1	MOV AH,48	    B4 48
xxxx:0ed3	INT 21		    CD 21

Search for this piece of code with the 's' command in debug:

	s 100 l 7fff bb 0a 00 b4 48 cd 21 <CR>

There should only be one occurence of this sequence. In my version of PC-DOS
2.1 (?) it is located at offset 'ece' in the file.

To allocate a larger environment space change the value which is loaded
into the 'bx' register using the 'e' command:

	e ecf 20 <CR>

The example here would allocate 20 hex paragraphs to the environment.
Complete the patch by writing the modified COMMAND.COM with the 'w' command:

	w <CR>

(No parameters are needed with the 'w' if these are the only operations
which you did while in debug.)


DOS 3.1

Several months ago I also went through this process on DOS 3.1 because
my manual does not have anything I could find about switches to expand 
the environment!!

I cursed Microsoft for not providing a mechanism (so I thought) to do this
especially when I discovered that the size for the environment was no longer
hard coded as it had been in MS-DOS 2.x. My curses now are redirected
toward IBM for not documenting the feature in their manuals.


Jim Vallino
ihnp4!princeton!siemens!jrv