views:

28

answers:

1

if i change hkey_current_user/environment/path in registry, get-env "PATH" doesn't reflect the new value unless I close rebol console and re_open it.

A: 

Environment variables are not the same things as Registry Keys.

Windows does consult particular registry keys when it is setting up the default environment a program gets when it launches from the shell. However, changing it won't inject those values into the environments of already running processes (in Rebol or any other program). Conversely, if you set things in the environment of a running program you won't see those changes reflected back into the registry.

If you want to read registry values, there is an API for that:

http://www.rebol.com/docs/sdk/registry.html

BUT rightly or wrongly: it is generally accepted (on every platform I've used) that one must exit a program and restart it in order to refresh environment variables from system settings. If you try and work around that, you may cause more complexity and confusion than anything else.

Hostile Fork
I tried with dos set path, you're right it doesn't refresh :(but couldn't rebol be more intelligent than MS and really read directly from registry ;)
Rebol Tutorial
SDK is great but this is kind of basic needs which should be in standard rebol version.
Rebol Tutorial
I'm sure that interfacing with environment variables and the registry "better" than other applications is not a priority. To the extent that Rebolers want to reimagine how these kinds of problems are solved, they would do so in a system where the key/value database is stored natively as Rebol objects... the code for manipulating them Rebol, etc.
Hostile Fork
What if you use CALL to shell out to another REBOL instance, do the get-env there, and capture the returned values?
Sunanda
Not running Windows at the moment, but if CALL uses CreateProcess under the hood, the only options for that spawned process is to inherit the environment of the parent or pass in a custom block. I don't think there's "get the environment a new user-launched process would start with". There may be a mysterious Windows-only API that facilitates that, and Rebol may use it somewhere, but I'd (again) be wary of such "magic", and it is certainly not cross-platform.
Hostile Fork
@sunanda I didn't think about it, great idea.
Rebol Tutorial
@HostileFork Rebol has some functions that are not cross-platform already so why not add one more :)
Rebol Tutorial
@HostileFork when I have choice I use Rebol structures but when I need to interface with other systems that require Env variables I have no choice.
Rebol Tutorial