Contents of the BSET.DOC file
Copyright 1989, Brad Stephenson
I've often wanted a way to exceed the DOS limitation of 127 characters
for an environment variable. Most of the time I wanted to be able to
set my DOS PATH to include a large number of directories without
resorting to the SUBST command.
BSET (Big SET) provides that ability. It reads strings from a data
file and places those strings in the "parent" environment. It's as if
you typed in the strings on the command line using the SET command,
| except you are limited to 1023 characters, not 127.
DOS can and will use a PATH longer than 127 characters - it's only the
SET command that limits you. My own PATH is now 265 characters; I've
seen no adverse effects.
| BSET's syntax is: BSET [filename]
where 'filename' is the data file containing your environment
| If no data file name is entered on the command line, BSET shows the
| contents of the environment. This feature will be of use to those
| using DOS version 4.0x - it's SET command truncates the display of
| environment variables at 127 bytes (you can still use longer variables
| with DOS 4.0x, but you cannot see their contents using SET). BSET's
| environment display will show the entire variable.
| A BSET data file can contain strings that are up to 1023 characters
long. Do not allow your word processor to wrap long lines. Each
string must be terminated in a CR/LF character. Use the same syntax
you would use with the DOS SET command (varname=varstring).
BSET will delete an environment variable if there are no characters
after the '=' (see example). If you specify a variable name that
already exists in the environment, the old variable will be deleted
and the new one added.
EXAMPLE DATA FILE CONTENTS:
In the example, the environment variables PATH and QMODEM are added
| to the environment, COMPROG2 is deleted, and a PROMPT is set.
BSET produces error messages and DOS Errorlevel codes when it
encounters problems. If you exceed available environment space, for
example, BSET will display an error message, then proceed with the
next string in the data file.
The DOS Errorlevel returned reflects the last error found. BSET will
return the following values:
0 - No problems
1 - DOS version is not 2.0 or higher
2 - Insufficient room in the environment
3 - Environment string data is invalid
4 - DOS environment table is corrupted (before any changes)
5 - Data file name not specified on command line
6 - Data file cannot be found
If you are having problems running out of environment space, use the
SHELL command in your CONFIG.SYS file. A typical SHELL command:
SHELL=C:\DOS\COMMAND.COM /P /E:400
For DOS 3.21, the '/E:400' expands the environment space to 400 bytes.
For DOS version 3.1, the '/E' value specifies the number of 16-byte
paragraphs, not the total number of bytes. See your DOS manual for
If your are attempting to modify an environment from a secondary copy
of COMMAND (as in a "drop-to-DOS" mode from another application), you
might be surprised to find insufficient room. This is due to the
method DOS uses to copy the environment to a child process. In
general, DOS uses the following rules when establishing environment
space for a child process:
1. If the master environment has not been expanded using the
SHELL command, a child process will receive an environment
that is 160 bytes long (differs with some older versions
of DOS). This "baseline" size is kept even if less than
160 bytes of strings are actually in the master environment.
2. If the master environment has been expanded, a child process
receives all the environment strings from the parent (if
the EXEC call is set up to do so), but the total size of
the passed environment is NOT the size specified in the
SHELL command. The total size is actually the number of
bytes USED in the master environment plus enough slack
to fill to the next paragraph (16 bytes) boundary.
Therefore, if you need the ability to add environment variables when
running a secondary copy of COMMAND.COM, you should add 'dummy'
variables to the master environment. DOS will then create a larger
environment for the child process. When you are ready to modify the
environment from the secondary copy of COMMAND, first delete the 'dummy'
and then add your new variable.
USING BSET IN AN AUTOEXEC FILE
You should be aware of a couple of DOS idiosyncrasies when using BSET
in an AUTOEXEC.BAT. First, do NOT use BSET to set up your COMSPEC
variable! Your system will probably hang. Second, make sure you have
a small PATH already set up before using BSET to create your long PATH
variable. The PATH should be the last entry in the environment when
calling BSET (this requirement only exists if you are using BSET in an
The following is an excerpt from my functioning AUTOEXEC.BAT file:
| The PROMPT statement also requires some special consideration.
| Normally your AUTOEXEC.BAT file has the statement 'PROMPT promptstring'.
| Note that there is no '=' sign. If you are using BSET to set your
| PROMPT, be sure to format it as an environment variable
| (varname=varstring). An example of a correct PROMPT statement in a
| BSET data file is 'PROMPT=$p$g'.
Version 1.01 - Corrected problem of not incrementing line count for
11/19/89 blank lines.
Added routine to check for '=', '|', '<', and '>' in
environment variable data portion of string. If those
characters are found, data is invalid.
| Version 1.10 - Added the ability to display the contents of the
| 11/29/89 environment. Also added the display of environment
| size (total, used, free) information.
BSET uses an algorithm similar (but not identical) to one shown in
Barry Simon's article in PC Magazine Volume 8 Number 20. Refer to
that article for information on finding the "parent" DOS environment.
BSET is free software. The author retains all rights to the program,
but you may distribute BSET as long as there is no fee charged.
Jenison, MI 49428
Compuserve ID 71620,1035