HOWTO: Inheriting Environment Variables for MS-DOS apps on Win95

ID: Q152648

The information in this article applies to:

SUMMARY

When launching 16-bit MS-DOS applications or batch files on Windows 95 from a 32-bit process using the CreateProcess() Win32 API, a changed or modified environment will not be inherited if creation of the MS-DOS application requires a new console window. To cause the environment to be successfully inherited, the Win32 process can launch a 32-bit console application which will inherit the Win32 parent's current or specified environment variables. The 32-bit console application can then launch the 16-bit MS-DOS application or batch file, causing the MS-DOS application to inherit the Win32 parent's console window and its environment variables.

MORE INFORMATION

The lpEnvironment parameter passed to CreateProcess()API allows programmers to specify an environment string for the process to be launched. If no environment is specified, the child process will inherit the parent's current environment variables.

On Windows 95, the parent's modified environment or specified environment string will not be inherited if the child is a 16-bit MS-DOS application or batch file. If the parent process is a Win32 console application, the 16- bit MS-DOS application or batch file can inherit the Win32 process' console and successfully inherit the environment variables of the parent.

For console-less Win32 applications to launch MS-DOS applications or batch files with an inherited or specified environment string, they must first launch a Win32 console process that will successfully inherit the environment. The Win32 console application can then launch the MS-DOS application or batch file, causing the spawned 16-bit application to inherit the Win32 parent's console and its environment variables.

Additional query words: win95 w95 pif oldapps dosapps dos

Keywords          : kbprg kbConsole kbKernBase kbGrpKernBase 
Platform          : WINDOWS
Issue type        : kbhowto

Last Reviewed: May 15, 1997