John
John

Reputation: 1119

Does a process inherits its Environment Variables from its parent or does it get them from Windows?

Each process in Windows has its own Environment Variables. But I am not sure how does a process gets its Environment Variables, does it get them from the "global Environment Variables" that Windows provides, I mean those Environment Variables:

enter image description here

Or does it inherit them from its parent process (and only the first parent process gets its Environment Variables from Windows)?

Upvotes: 4

Views: 3861

Answers (1)

jweyrich
jweyrich

Reputation: 32240

As stated in Environment Variables (Windows), a child process inherits all environment variables from its parent process. Additionally, a parent process may use CreateProcess to create a child process and pass a new set of environment variables to it.

Apart from that, programs that are started by the command processor (CMD) inherit the CMD environment variables, which are also listed in the screenshot you attached to your question.

Upvotes: 4

Related Questions