Elevation Level and Environment Varibles
Keywords: Manifest Elevation Level UAC Environment Varibles Win7 EnvItemize
Question:
Yesterday, I attempted to use the EnvItemize function to import the list of environment strings. To my dismay, the new string that I defined, via the SET command, was absent from the list.
My procedure was as follows.
- Open a command prompt window.
- Run the SET command.
- Start WinBatch Studio from the command prompt.
- Load the script containing the EnvItemize function.
- Run the script in debug mode, with a breakpoint.
- Examine the string returned by EnvItemize.
I have a couple of theories about why this is so. Before I spend too much more time investigating, I decided to ask for input.
Please advise.
Answer:
The following MSFT blog post partially explains what is going on
http://blogs.msdn.com/b/cjacks/archive/2008/10/29/why-don-t-elevated-applications-receive-environment-variables-set-by-non-elevated-calling-process.aspx
What is relevant is how the application is manifested and whether or not UAC is enabled. What may be a bit counter intuitive and is not mentioned by Mr. Russinovich is that even when the launching application is already elevated, the launched admin privilege manifested application will not be a true child process of the launching application.
Article ID: W18312
Filename: Elevation Level and Environment Varibles.txt
File Created: 2012:05:14:10:46:58
Last Updated: 2012:05:14:10:46:58