Effect of Spawning COMMAND.COM on the Environment (68927)



The information in this article applies to:
    Microsoft MS-DOS operating system 3.1
    Microsoft MS-DOS operating system 3.2
    Microsoft MS-DOS operating system 3.21
    Microsoft MS-DOS operating system 3.3
    Microsoft MS-DOS operating system 3.3a
    Microsoft MS-DOS operating system 4.0
    Microsoft MS-DOS operating system 4.01
    Microsoft MS-DOS operating system 5.0
    Microsoft MS-DOS operating system 5.0a
    Microsoft MS-DOS operating system 6.0
    Microsoft MS-DOS operating system 6.2
    Microsoft MS-DOS operating system 6.21
    Microsoft MS-DOS operating system 6.22

This article was previously published under Q68927

SUMMARY

If you spawn another COMMAND.COM, the child COMMAND.COM has its own environment space allocated to it. The size of this environment space is at least the minimum environment size of 160 bytes. If you start the child COMMAND.COM with the /e:<size> switch, the child's environment space is equal to the indicated <size> in bytes, rounded up to the nearest 16-byte boundary. The maximum allowable environment size is 32,768 bytes.

A copy of the parent process's environment variables are placed in the child's environment space. If the parent's environment variables exceed the space allocated to the child, the child's environment space is automatically increased to allow for the parent's variables. Once again, the environment space is rounded up to the nearest 16-byte boundary. Any changes made to the child's environment have no effect on the parent's environment.

MORE INFORMATION

By using the /e:<size> switch on COMMAND.COM, you can force the allocation of that much memory to the environment. In MS-DOS versions 5.0 and later, a default environment space of 256 bytes is allocated if no /e switch is used (lesser amounts can be specified using the /e:<size> switch). In earlier MS-DOS versions, 160 bytes is the default. The environment can grow beyond the allocated size, but this can occur only if there is free (unallocated) memory available that is contiguous to the currently allocated environment block.

Modification Type: Major Last Reviewed: 5/12/2003
Keywords: KB68927