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

Last reviewed: May 13, 1997
Article ID: Q152648
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface included with: - Microsoft Windows 95

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 : BseCon kbprg
Platform : WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 13, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.