How To Modify the Environment for a Spawned Process (11997)



The information in this article applies to:

  • The C Run-Time (CRT), when used with:
    • Microsoft C/C++ for MS-DOS 7.0
    • Microsoft Visual C++ for Windows, 16-bit edition 1.0
    • Microsoft Visual C++ for Windows, 16-bit edition 1.5
    • Microsoft Visual C++, 32-bit Editions 1.0
    • Microsoft Visual C++, 32-bit Editions 2.0
    • Microsoft Visual C++, 32-bit Editions 4.0
    • Microsoft Visual C++, 32-bit Editions 5.0
    • Microsoft Visual C++, 32-bit Editions 6.0

This article was previously published under Q11997

SUMMARY

The text below discusses the process through which an application can modify the PROMPT environment variable in a spawned process. Use the same procedure to modify any environment variable in a spawned process.

PROMPT is an environment variable used by MS-DOS, OS/2, and Windows NT. To change the value for the PROMPT environment variable, use one of the following two methods to specify the environment in which a child process runs.
  • Use one of the spawn*e() functions. See the run-time library reference manual or the online help file provided with your compiler for specific information about the spawn() family of functions.
  • Use the putenv() function to modify the environment in which your application executes, then start the child process with one of the spawn() functions. See the run-time library reference manual or the online help file provided with your compiler for specific information about the putenv() function.
In general, a process can alter only the environment in which a child process will run. The C run-time library functions simulate the ability to alter the environment space in which the current process runs by making a copy of the environment when the process starts up and allowing the process to modify the copy of the environment.

Modification Type:MinorLast Reviewed:7/2/2004
Keywords:kbCRT kbhowto KB11997