[comp.windows.ms] Environment space for DOS appl. under Windows

hogstedt@ae.chalmers.se (PER HOGSTEDT) (10/22/90)

Hi, 

 When running DOS applications from Windows I get too little environment
space for my application. Windows allocates 224 bytes in standard mode (I
think).
How can I tell Windows to allocate more environment for my DOS application?
Yes - I have tried TFM as well as all *.TXT files I can find without
any success.

Any bright ideas?

Regards,
Per Hogstedt
hogstedt@plab.se or hogstedt@ae.chalmers.se

DRJ100@psuvm.psu.edu (Daniel R. Jeuch) (10/22/90)

In article <433.2721eb3c@ae.chalmers.se>, hogstedt@ae.chalmers.se (PER HOGSTEDT)
says:
>
>Hi,
>
> When running DOS applications from Windows I get too little environment
>space for my application. Windows allocates 224 bytes in standard mode (I
>think).
>How can I tell Windows to allocate more environment for my DOS application?
>Yes - I have tried TFM as well as all *.TXT files I can find without
>any success.
>
>Any bright ideas?

Only one which worked for me:

Change COMMAND.PIF to execute COMMAND.COM /E:#### where #### is the size of the
environment space you want...
-----
Daniel R. Jeuch                   Microsoft Corp. Student Rep.
10 Vario Blvd., Box 185           DRJ100@PSUVM, drj100@psuvm.psu.edu
State College, PA  16803          (814) 867-4622, (800) 232-5129

ckinsman@eecs.wsu.edu (Chris Kinsman - EE major) (10/24/90)

In article <433.2721eb3c@ae.chalmers.se> hogstedt@ae.chalmers.se (PER HOGSTEDT) writes:
>Hi, 
>
> When running DOS applications from Windows I get too little environment
>space for my application. Windows allocates 224 bytes in standard mode (I
>think).
>How can I tell Windows to allocate more environment for my DOS application?
>Yes - I have tried TFM as well as all *.TXT files I can find without
>any success.
>
>Any bright ideas?
>
I don't know if this is bright but it works.  do a SET DUMMY1=111111111111111
(256 characters)  This will give you an additional 256 bytes or so of
environment space.  Run your program from a batch that does a SET DUMMY1= 
before running your program.

Chris

cchapman@msd.gatech.edu (Chuck H. Chapman) (10/24/90)

>In article <433.2721eb3c@ae.chalmers.se> hogstedt@ae.chalmers.se (PER HOGSTEDT) writes:
>Hi, 
>
> When running DOS applications from Windows I get too little environment
>space for my application. Windows allocates 224 bytes in standard mode (I
>think).
>How can I tell Windows to allocate more environment for my DOS application?
>Yes - I have tried TFM as well as all *.TXT files I can find without
>any success.
>
>Any bright ideas?
>
You could also try putting the following line in your CONFIG.SYS:

SHELL=\path to where command.com is\COMMAND.COM /P /E:XXX

where XXX is the number of bytes to allocate for your environment space.
The default is 256 bytes I believe.  Try something like 384 or 512.

Chuck
--
Chuck H. Chapman  (GTRI/STL/MSD)             (404) 528-7168
Georgia Institute of Technology, Atlanta Georgia, 30332
uucp:     ...!{allegra,amd,hplabs,ut-ngp}!gatech!msd!cchapman
Internet: cchapman@msd.gatech.edu

mikel@pyrps5.pyramid.com (Mike Lipsie) (10/24/90)

In article <1990Oct24.032517.21201@eecs.wsu.edu> ckinsman@yoda.UUCP (Chris Kinsman - EE major) writes:
>In article <433.2721eb3c@ae.chalmers.se> hogstedt@ae.chalmers.se (PER HOGSTEDT) writes:
>>
>> When running DOS applications from Windows I get too little environment
>>space for my application. Windows allocates 224 bytes in standard mode (I
>>think).
>>How can I tell Windows to allocate more environment for my DOS application?
>>Yes - I have tried TFM as well as all *.TXT files I can find without
>>any success.
>>
>I don't know if this is bright but it works.  do a SET DUMMY1=111111111111111
>(256 characters)  This will give you an additional 256 bytes or so of
>environment space.  Run your program from a batch that does a SET DUMMY1= 
>before running your program.

Well ... That might work but I wouldn't count on it.

When Windows "launches" a program it starts another copy of COMMAND.COM.
Just edit the associated .PIF (or create it if there is none) to have
an environment space that is big enough.  For example, /e:512 /p
would give you 512 bytes of environment (minus whatever is already 
defined).

-----------
Mike Lipsie                               mikel@pyramid.com
Pyramid Technology Corp, Mountain View, CA  +1 415 335 8657
"Toto kansasoseum non est cognito" -- Phil Frank

mshiels@tmsoft.uucp (Michael A. Shiels) (10/25/90)

Windows Applications can also call the normal DOS spawn functions with
no problems at all.  

Ie a windows based CRON?

BUT THERE IS ONE BUG.  YOU CAN NOT PASS A NEW ENVIRONMENT TO THE SUBPROGRAM
ALL YOU CAN PASS IS A 0 IN THE ENVIRONMENT POINTER SO THAT IT WILL INHERIT THE
ENVIRONMENT OF THE PARENT PROGRAM (WINDOWS!).  THERE IS A FIX THOUGH.  The
DOS int 21 function 4B exec control block must be in the same segment as
the environment sort if the following form.  

segment:0
	environment variables

	:x
	is where the control block is located and it's environment segment
is set to "segment"

jcmorris@mwunix.mitre.org (Joe Morris) (10/25/90)

In a recent article hogstedt@ae.chalmers.se (PER HOGSTEDT) writes:
 
> When running DOS applications from Windows I get too little environment
>space for my application. Windows allocates 224 bytes in standard mode (I
>think).
>How can I tell Windows to allocate more environment for my DOS application?

Other responses to this have suggested a variety of ideas:

> Edit CONFIG.SYS to include a larger environment space (/e:nnn)

Won't help.  Windows calls up a fresh copy of COMMAND.COM to start a
DOS window and does not bother to propagate the /e:nnn used at boot 
time.  You get the default allocation of environment space only, or
the space required to hold the current environment, whichever is larger.

> Create a placeholder in the environment before entering Windows (e.g.,
> SET DUMMY1=1111111111...

Works, but it's a hassle.

> Make the default .PIF file specify a larger environment

Works for the DOS window, but you have to play this game for each non-
Windows app you use.

====

FWIW, I finessed the problem some time ago (pre-WIN3) by patching COMMAND.COM
to change the default environment space.  In addition to fixing the Windows
problem it simultaneously fixes the shortage of environment space in other
(non-WIN3) situations where a program permits you to shell back to the DOS
prompt.

(An aside to Microsoft: Why do I have to play this game, and why can't 
COMMAND.COM be set up to use the CONFIG.SYS value every time it's loaded?
Any chance this might appear in DOS5?)

As usual, your milage may vary, and if you use this patch you're on your own.
It works for me with no problems, but for some reason some people use PC's
with imperfect (meaning not identical to my) configuration.

Here's the patch for PC-DOS 3.3:

=-=-=-=-=-=-=-=-=-=  begin included file  =-=-=-=-=-=-=-=-=-=

This patch changes the default environment size in COMMAND.COM for DOS 3.3
from its IBM-provided value of 160 bytes.

The COMMAND command (both in the SHELL statement in CONFIG.SYS and in
the command which establishes a secondary command processor) accepts
the /E:xxxx parameter, but when a secondary processor is started it
does not honor the size specification of its parent.  This can cause
significant problems if a user invokes functions which require more
environment space than is available while in a secondary command processor
environment.

The patch will work for PC-DOS 3.3 only.  The concept is probably applicable
for other DOS variants and other releases, but the verify code (and possibly
the patch data) will differ.

The value to be changed represents a (two-byte) word containing the size of
the default environment space in paragraphs (16-byte blocks).  Since the
80*86 architecture inverts the sequence, the low-order byte appears first.
The default value is 160 bytes (hex 00A0), so the original data is hex 0A 00;
to patch the file to default to 512 bytes (hex 0200) the data should be
changed to hex 20 00.

Note that the low-order zero is not present.  To summarize:

   For this much space...insert this value...inverted

160 bytes (10 paragraphs)      000A           0A 00
256 bytes (16 paragraphs)      0010           10 00
512 bytes (32 paragraphs)      0020           20 00

The installation script to set a 512-byte default if typed from the console.
Executing this from a file would not show exactly the same material.

C:\> debug command.com
- d eb4 eb9                     (show the data where we will patch)
xxxx:0EB0              C7 06 60 16 - 0A 00                       ......

- e eb8 20                      (make the actual patch)

- w                             (write the file back to disk)
Writing 62DB bytes
- q                             (exit DEBUG)
C:\>

=-=-=-=-=-=-=-=-=-=  end included file =-=-=-=-=-=-=-=-=-=

Joe Morris

rm3@stc06.ornl.gov (MCBROOM R C) (11/03/90)

In article <124411@linus.mitre.org> jcmorris@mwunix.mitre.org (Joe Morris) writes:
>In a recent article hogstedt@ae.chalmers.se (PER HOGSTEDT) writes:
> 
>> When running DOS applications from Windows I get too little environment
>>space for my application. Windows allocates 224 bytes in standard mode (I
>>think).
>>How can I tell Windows to allocate more environment for my DOS application?
>
>Other responses to this have suggested a variety of ideas:
>
>> Edit CONFIG.SYS to include a larger environment space (/e:nnn)
>
>Won't help.  Windows calls up a fresh copy of COMMAND.COM to start a
>DOS window and does not bother to propagate the /e:nnn used at boot 
>time.  You get the default allocation of environment space only, or
>the space required to hold the current environment, whichever is larger.
>
>> Create a placeholder in the environment before entering Windows (e.g.,
>> SET DUMMY1=1111111111...
>
>Works, but it's a hassle.
>
>> Make the default .PIF file specify a larger environment
>
>Works for the DOS window, but you have to play this game for each non-
>Windows app you use.
>
>====
>
>FWIW, I finessed the problem some time ago (pre-WIN3) by patching COMMAND.COM
>to change the default environment space.  In addition to fixing the Windows
>problem it simultaneously fixes the shortage of environment space in other
>(non-WIN3) situations where a program permits you to shell back to the DOS
>prompt.
>
>(An aside to Microsoft: Why do I have to play this game, and why can't 
>COMMAND.COM be set up to use the CONFIG.SYS value every time it's loaded?
>Any chance this might appear in DOS5?)
>
On My Model 50Z in standard mode ZipManagers environmental editor shows the
full space specified in config.sys as being passed to the dos invocation.

rajesh@rtangri1.EBay.Sun.COM (Rajesh Tangri) (11/22/90)

Hi:

I am a contractor at Sun Microsystems, Software Engg. in Milpitas.  I have
been at Sun for about 1.2 years  and have worked on 4.0.3 based Realtime OS 
and 4.0.3, 4.1 based SparcEngine 1E product.  My manager lacks funding
for me to begin on a new project, therefore, I am ** available to start
on a new contract around Dec 15, 90 **.

I am a senior consultant with about 5 Years of full-time industry consulting
experience in both DOS and UNIX, especially with BSD 4.2, SVR4 internals
knowledge, Networking, Realtime OS design, UNIX device drivers,
distributed databases: ISAM, Sybase, X-Windows applications, DOS internals,
MS Windows 3.0 applications. 

Please e-mail me (until Dec 15, 90) or call me at (408) 732-4892 in case you
need my services or you know someone who does.  The job location boundary for
me to commute is around the South Bay in Silicon Valley.  I will fax or mail
my resume immediately. 

Thanks in advance,


Rajesh Tangri