MS-DOS 6.22 Master Environment Block Size Limit

In MS-DOS 6.22, the default size limit of the master environment block is 256 bytes. This article covers the default memory allocation for environment variables in MS-DOS 6.22, the common errors encountered when this limit is exceeded, and the exact steps required to expand the environment space using the CONFIG.SYS file.

Default Size and Purpose

The master environment block in MS-DOS 6.22 is allocated by COMMAND.COM upon system boot and is set to 256 bytes by default.

This memory space is reserved strictly for global system variables, such as:

  • PATH
  • PROMPT
  • TEMP or TMP
  • Custom user-defined variables created via the SET command

The "Out of environment space" Error

Because 256 bytes is a relatively small space, adding lengthy directory strings to the PATH or loading multiple batch files that declare variables can quickly exhaust this block. When the limit is reached, MS-DOS issues the following runtime error:

Out of environment space

When this happens, any subsequent SET commands fail, and the intended variables are discarded.

How to Increase the Environment Block Size

To increase the size beyond the 256-byte default, you must configure the SHELL command in the CONFIG.SYS file using the /E parameter.

  1. Open C:\CONFIG.SYS in a text editor (such as MS-DOS EDIT).
  2. Add or modify the SHELL directive to specify the desired environment size in bytes:
SHELL=C:\DOS\COMMAND.COM C:\DOS\ /E:1024 /P
  • C:\DOS\COMMAND.COM: Specifies the path to the command interpreter.
  • C:\DOS\: Specifies the directory where COMMAND.COM looks for itself when reloading.
  • /E:1024: Sets the new environment size (in this example, 1,024 bytes).
  • /P: Makes the command interpreter permanent so that exiting the shell does not halt the system, and forces DOS to execute AUTOEXEC.BAT on startup.

Permitted Size Range

MS-DOS 6.22 allows the environment block size specified by the /E switch to range from a minimum of 160 bytes to a maximum of 32,768 bytes (32 KB). Values are typically rounded up to the nearest multiple of 16 bytes.