COM pt 3–More shell
Last time we looked at the Environment parameterized property
If you ran the script in part two the output would have contained things like
We need to be able to resolve the variable %SystemRoot% part to the full path
We can take the script from part 2 and modify it slightly. Once we have the environmental variables for each area we loop through them and find those that contain the pattern “%.%”. This is a simple regular expression (I only do simple regex. Maybe I’ll get more adventurous after the March UG group when we have a guest speaker on regex) that looks for two % signs separated by some characters.
If we find that we split on the % and take the second element – push it through the ExpandEnvironemtStrings method and plus the result back into the environmental variable.