Goal
We are using environment variables like %logonserver%
and %userdomain%
in our .NET application's configuration files, to support configuration freedom to application managers. When parsing the configuration file a call to Environment.ExpandEnvironmentVariables resolves the actual value.
Problem
However it seems it can not expand environment variables with substitutions like:
%logonserver:~2%
(skips the first two characters)%logonserver:\\=%
(replaces the backslashes with an empty string)
When I call Environment.ExpandEnvironmentVariables("%logonserver:~2%")
the method just returns the same string: %logonserver:~2%
, instead of the expanded and substituted variable like a command line call would: echo %logonserver:~2%
.
Questions
- Is there anything I'm doing wrong?
- What's an alternative to accomplish this goal in .net?
Thanks in advance.