[net.micro.pc] COMMAND.COM and environment strings

kneller@ucsfcgl.UUCP (Don Kneller%Langridge) (06/18/86)

I was trying to use COMMAND.COM to exec a batch file from within another
program by execking:

	command /C batch.bat

This works fine unless the batch file has commands that try to expand
the environment (eg "set xyzzy=a magic word").  Then COMMAND.COM complains
with "Out of environment space".  In fact the following:

	C> command /C set xyzzy=a magic word

causes the same error message.  With COMMAND.COM there is an optional
path argument that can also be given:

	C> command C: /C set xyzzy=a magic word

This works, but the current environment variables aren't copied for the
new COMMAND.COM.  So the following happens:

	C> set xyzzy=a magic word

	C> echo %xyzzy%
	a magic word			(the DOS response)
	C> command /C echo %xyzzy%
	a magic word			(this works ok)
	C> command C: /C echo %xyzzy%
	xyzzy%				(oops - environment variable
					xyzzy is not there anymore)

Thus there is a tradeoff between having the current environment variables
and being able to set new environment variables.  Although I have a work-
around for my particular situation, does anyone know of a general solution?
I've tried this on PCDOS 2.0 and 3.1 with the same consequences.

This is *not* a problem with having a small environment.  I think it is
a problem with COMMAND.COM being loaded after the current environment
but trying to modify the current environment.  If it tries to add to the
current environment it sees that it needs more memory, but it can't get
more memory because there is a program using the memory it wants.  Of
course, the program using the memory is the loaded version of COMMAND.COM.
-- 
	Don Kneller
UUCP:	...ucbvax!ucsfcgl!kneller
ARPA:	kneller@ucsf-cgl.ARPA
BITNET:	kneller@ucsfcgl.BITNET

jrv@siemens.UUCP (06/20/86)

When the environment is sized for the initial running of COMMAND.COM the
default of 160 bytes (or expanded if you have put in the proper options
on SHELL or pathed COMMAND.COM etc...) limits how big the operating
system copy of the environment can grow. When a transient program gets
loaded the copy of the environment it gets passed only contains the
part of the environment which is used. Any unused space does not get 
copied. The basic problem is to create some dummy space in the environment.
You might try defining several environment variables which take up a lot
of space. Then when the second copy of COMMAND.COM is run you can get
this space back by undefining the variables in the batch file run by this
transient COMMAND.COM.

Jim Vallino
Siemens Research and Technology Lab.
Princeton, NJ
{allegra,ihnp4,seismo,philabs}!princeton!siemens!jrv