Jump to content

Environment variable expansion problem.

Recommended Posts

When getting values containing environment variables from the registry, you may get the %var% text.

Sure, I can replace the % and do a EnvGet to get the "real" value of it.

But what if the returned value is say: %SystemRoot%\Temp

It there a more simple way to get it to say: C:\Windows\Temp than using StringMid and replacing % + EnvGet.

And finally, yes I am aware of the macros @WindowsDir, @SystemDir and @TempDir. They are all very nice, but do not provide the solution to my problem...

-----some examples-------

The first example will result in %SystemRoot%.

$test = regread("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","windir")


The second example will result in %SystemRoot%\TEMP on most machines.

$test = regread("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","Temp")


I gotta be the biggest nutcase ever for trying something this stupid...

Link to post
Share on other sites

Only literal strings get expanded so that wouldn't work.

I didn't know that. (I had problems before, but they're solved now.)

Can you make it that you can read env. variables using string variables?

Edited by SlimShady
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...