Patching COMMAND.COM default environment size

This information comes from the XSET package, the program that allows you to put EVERYTHING you want in a DOS environment variable and use it as if you had assigned it the value with the standard DOS command SET.

DOS provides a method to tell COMMAND.COM how much environment space you want:


where nn is the number of bytes you want.

You may use this feature in your CONFIG.SYS file with the SHELL command:


You can read more about this in your DOS manual.

The problem is when an application (any DOS shell like Norton Commander or PC-Tools for example) launches a new copy of COMMAND.COM. The default environment size for a new COMMAND.COM being loaded is hard-coded in the COMMAND.COM program and is in most of the case largely insufficient.

Here is the way to change this value.

The presented sections of code are from MS-DOS 5.00 dis-assembled with DEBUG so that those with other versions of DOS find the offsets for their COMMAND.COM. In other DOS versions, the section of code to be patched is unchanged, it is simply shifted in position so it's just a question of locating the correct offsets by searching for strings of bytes from the sections of code listed below. The main trick here is to avoid addresses in the code which are likely to be different (most absolute addresses will be different while relative addresses may or may not be different). Assuming you're handy with DEBUG or a similar debugger and know some 8088 assembly, you should be able to pull it off. If DEBUG's search command is too limited, you might try unassembling the whole COMMAND.COM to a text file and using an editor or lister utility to search.

ENVIRONMENT SIZE: This example is for MS-DOS 5.0

-u 165b

1111:165B 58 POP AX
1111:165C C706C01E5100 MOV WORD PTR [1EC0],0051
1111:1662 C706BE1E1000 MOV WORD PTR [1EBE],0010 <>
1111:1668 BAD498 MOV DX,98D4
1111:166B B104 MOV CL,04
1111:166D D3EA SHR DX,CL
1111:166F 8916CE1E MOV [1ECE],DX
1111:1673 2BC2 SUB AX,DX
1111:1675 A39802 MOV [0298],AX
1111:1678 A12C00 MOV AX,[002C]

The default value for the environment size is 10 paragraphs of 16 bytes. So, to change your default environment size to 1280 (50 paragraphs), type:

-E 1666 50 00

Here are the offsets for some MS-DOS versions:

6.22: 1777 (default size: 20h * 16 bytes = 512)
6.20: 1777 (default size: 20h * 16 bytes = 512)
6.00: 1767 (default size: 20h * 16 bytes = 512)
5.00: 1666 (default size: 10h * 16 bytes = 256)
3.30: 0Eb8 (default size: 0Ah * 16 bytes = 160)

Search for ''C7 06 xx xx 10 00' for other DOS versions
- replace '10' by default size ('0A', '20', ...)