MS-DOS 6.22 Environment Variable Limits
MS-DOS 6.22 does not place a fixed numerical limit on the total number of environment variables you can define. Instead, the operating system limits the total memory size allocated to the environment block itself. This article explains how the environment table is structured, the default and maximum byte limits, and how to expand the environment space to accommodate more variables.
The Byte Limit vs. Variable Count
In MS-DOS 6.22, environment variables are stored in a contiguous
block of memory as null-terminated strings in the format
NAME=VALUE. Because the operating system only tracks the
memory boundaries of this block rather than the quantity of individual
records, the actual number of variables you can define depends entirely
on the combined character length of the variable names and their
values.
If you attempt to define a variable when the allocated block is full,
MS-DOS returns the standard error message:
Out of environment space.
Default and Maximum Sizes
- Default Environment Size: By default, MS-DOS 6.22
allocates 256 bytes for the master environment space
managed by
COMMAND.COM. - Minimum Environment Size: The minimum configurable size is 160 bytes.
- Maximum Environment Size: The maximum configurable size is 32,768 bytes (32 KB).
Theoretical Maximum Number of Variables
Because every variable requires at least a name, an equals sign, an
assigned character, and a terminating null byte (\0), the
absolute minimum size for a single entry is four bytes (e.g.,
A=1\0).
Within the maximum 32 KB (32,768 bytes) allocation, the absolute
theoretical maximum is slightly over 8,000 minimal variables. In
practice, because common variables such as PATH,
PROMPT, and TEMP use dozens of characters
each, the realistic limit is significantly lower.
How to Increase Environment Space
To prevent Out of environment space errors and increase
the capacity for more variables, you must adjust the /E:
switch of the command processor in your CONFIG.SYS
file.
Add or modify the SHELL directive in
CONFIG.SYS:
SHELL=C:\DOS\COMMAND.COM C:\DOS\ /E:1024 /P
In this example, /E:1024 increases the environment size
from the default 256 bytes to 1,024 bytes. You can replace
1024 with any value between 160 and
32768 to suit your requirements. The /P switch
instructs DOS to make this shell permanent and automatically run
AUTOEXEC.BAT upon boot.