CreateProcess won’t eliminate duplicated variables from the environment block in lpEnvironment parameter
An application calls CreateProcess and passes an environment block as its lpEnvironment parameter.
If we have two definitions for the same variable but with different values in that block, we may expect that the child process gets the last value we set in the block when it queries for the variable. Instead, Windows returns the first value.
For more information on this issue, including potential causes, workarounds, and resolutions, see: Microsoft KB Article KB2505238.