How To Inheriting Environment Variables for MS-DOS apps on Windows 95, Windows 98, or Windows Me
Article ID: 152648
Article Last Modified on 11/21/2006
APPLIES TO
- Microsoft Win32 Application Programming Interface, when used with:
- Microsoft Windows 98 Standard Edition
- Microsoft Windows Millennium Edition
This article was previously published under Q152648
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 Microsoft Windows 95, Windows 98, or Windows Millennium Edition (Me)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: kbconsole kbhowto kbkernbase kbprogramming KB152648