# Increasing Environment Space

Batch files use MS-DOS environment variables to store data temporarily. Windows allocates a limited amout of memory for all environment variables. If your system is not configured to allow sufficient environment variable space, you may get "Out of environment space" errors when you run some batch files, which will cause the batch files to execute incorrectly. In this case, you must increase your MS-DOS environment space by following these steps:

## Step 1: Determine which PIF file is being used

When a program is executed, Windows searches for the PIF file "name.pif" in the following directories (where name is the base name of the executable file "name.com", "name.exe", or "name.bat"):

1. The directory that contains the executable file that you are running
2. The C:\WINDOWS\PIF directory
3. The directories specified by the MS-DOS "PATH" environment variable

If it does not find a PIF file in any of those directories, it searches the C:\WINDOWS\INF\APPS.INF file to determine if there are custom PIF values for the application.

If it still has not found a PIF file, it searches for a default PIF file named "_DEFAULT.PIF" in the following directories:

1. The C:\WINDOWS\PIF directory
2. The directories specified by the MS-DOS "PATH" environment variable

If it still has not found a PIF file, then the pre-defined system default values are used. The predefined system default uses the environment size specified by the Shell command in the Config.sys file.

## Step 2: Set the environment size

If you found a PIF file in Step 1 above, then follow these steps:

1. Right-click the PIF file, and then click Properties.

2. On the Memory tab, type or click the number of bytes the program requires (recommended: 4096) in the Initial Environment box, and then click OK.

   NOTE: The maximum amount of memory you can allocate for an MS-DOS program is 4096 bytes.

If you did not find a PIF file in Step 1 above, you must increase the default environment space for all MS-DOS programs by editing the Shell command in the Config.sys file. To do this, follow these steps:

1. Click Start, click Run, type sysedit in the Open box, and then click OK.

2. Click the Config.sys file, and then type a new Shell command or replace any existing Shell command with the following line

   > SHELL=C:\WINDOWS\COMMAND.COM /E:size /P

   Where, size is the size of the environment in bytes (recommended: 4096).

## Recommendations

You should increase the environment size for all applications by adding (or replacing) the following line to your Config.sys file:

> SHELL=C:\WINDOWS\COMMAND.COM /E:4096 /P

Then remove any "_DEFAULT.PIF" files, or set their Initial Environment to Auto. This will cause all applications to use the default environment size unless they have PIF files that specify otherwise.