Re: set PATH=%PATH%...

new topic     » goto parent     » topic index » view thread      » older message » newer message

> What I'm thinking is probably happening is that it's getting set correctl=
y but not saved. In Windows XP paths set with the SET command aren't saved =
when the command prompt closes.

You are entirely correct. In fact, each application gets its own
private environment variables, so any call to "set PATH=" is lost when
your app exits. The same holds true for SetEnvironmentVariable() in
the Windows API, all vars are lost when your app exits. These local
environment variables are really only useful for passing info to other
apps that your app spawns.

> What you need to do is go into the registry and change HKEY_LOCAL_MACHINE=
\SYSTEM\ControlSet001\Control\Session Manager\Environment\Path to the path =
you want. I had to do this in Perl for an installation script at my job bac=
k before I switched to Euphoria.

You are partially correct here. The only real way to force environment
variables is to add them to the registry. Typical installation
utilities (INNO, NSIS) do this when they install an app, like
Euphoria. I'm sure someone could make a small library that forces
environment variables using registry calls.

The correct registry location for User environment variables is
"HKEY_CURRENT_USER\Environment"

The correct registry location for System environment variables is
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment"

Also, keep in mind that environment variables are inherited. If the
Windows shell spawns your app, and you change an environment variable
in the registry, any call you make to getenv() won't see the change.
You'll have to set the variable twice, once with
SetEnvironmentVariable() (locally) and once in the registry
(globally).

Hope this helps, good luck.

~Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu