Sign in to follow this  
Followers 0
micor

Environment variable expansion problem.

3 posts in this topic

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")

msgbox(0,"Test",$test)

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

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

msgbox(0,"Test",$test)

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

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

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

Share this post


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
Sign in to follow this  
Followers 0