Environment Variable Load Order

  • Thread starter F. David del Campo Hill
  • Start date
F

F. David del Campo Hill

Dear All,

Does anyone know the order in which (system) environment variables are
loaded upon user log in?

I have an installation program which sets one system environment variable:

GTK_BASEPATH=C:\GTK

and changes the path system environment variable adding:

PATH=%GTK_BASEPATH%\bin;...

This works as expected just after the installation (PATH is effectively
C:\GTK\bin;...), but if you log out and log in again (as any user) you find
that %GTK_BASEPATH%\bin has NOT been "resolved" and files in that folder are
not part of the PATH. If you reload the environment variables manually
(right-click My Computer > Properties > Advanced > Environment Variables >
....; no need to actually make any changes, just press OK), then the PATH
includes C:\GTK\bin again (%GTK_BASEPATH% is being "resolved" to its value
when calling PATH).

My assumption is that environment variables are loaded in a certain order
when a user logs in, and PATH is being loaded before GTK_BASEPATH, so it is
ignoring the %GTK_BASEPATH%\bin at its beginning. But it is only an
assumption, so can anyone provide information on the order or priority of
environment variables?

Thank you for your help.

F. David del Campo Hill
 
P

Pegasus \(MVP\)

F. David del Campo Hill said:
Dear All,

Does anyone know the order in which (system) environment variables are
loaded upon user log in?

I have an installation program which sets one system environment variable:

GTK_BASEPATH=C:\GTK

and changes the path system environment variable adding:

PATH=%GTK_BASEPATH%\bin;...

This works as expected just after the installation (PATH is effectively
C:\GTK\bin;...), but if you log out and log in again (as any user) you
find
that %GTK_BASEPATH%\bin has NOT been "resolved" and files in that folder
are
not part of the PATH. If you reload the environment variables manually
(right-click My Computer > Properties > Advanced > Environment Variables >
...; no need to actually make any changes, just press OK), then the PATH
includes C:\GTK\bin again (%GTK_BASEPATH% is being "resolved" to its value
when calling PATH).

My assumption is that environment variables are loaded in a certain order
when a user logs in, and PATH is being loaded before GTK_BASEPATH, so it
is
ignoring the %GTK_BASEPATH%\bin at its beginning. But it is only an
assumption, so can anyone provide information on the order or priority of
environment variables?

Thank you for your help.

F. David del Campo Hill

I suspect that there is no published rule that says in which order
such variables are resolved. To make your installation robust, you
should hard-code this variable into the %path%. This is, in fact,
what the installation program should have don. After all, the value
of this variable was fully known to the installation program, hence
there is no justification to soft-code it into the %path%!

While you're at it you might as well tack it to the ***end*** of
the path. The most often used folders (c:\windows\system32 and
c:\windows) should be located at the beginning of the %path%,
for obvious reasons.
 
F

F. David del Campo Hill

Pegasus,

You misunderstand me: this is not MY installer, I am not building it or have
any chance of changing it save by e-mailing the developers and telling them
it is broken. But to do this I need to be able to point them to some
documentation that explains why it is broken. In the end I am going to have
to manually change the paths myself so that it works for the 31 machines I
need to install the software in.

Thanks anyway.

Anyone else has any information on the question I asked?

F. David del Campo Hill
 
P

Pegasus \(MVP\)

I am fully aware that you're not the author of the installer.
However, since you appear to be responsible for a number
of machines, you will have to correct the developer's
oversight. I would do it by creating the following batch
file on a share on your server:

@echo off
e:\setup.exe (assuming that drive E: is your CD drive)
setx -m path %path%;c:\Program Files\GTK_BASEPATH

Replace GTK_BASEPATH with the correct path for this
application. You can get setx.exe from the Windows Resource
Kit.You must, of course, test this batch file before you invoke
it on 31 PCs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top