cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
dudebigboy
Level 2

Resolving Environment Variable

Let's say I have two installers.

The first one install stuff and create a new environment variable used in the PATH as %var%

The second installer launch a batch file that needs to access the content of the %var%

The problem is that in the second installer, the batch is launched with the new path but unresolved. It still shows as %var%.

If I launch the same installer after a reboot, it correctly resolve the %var% with the specified path I need.

I think this is due to the fact msiexec is used as a service and services in general needs to have a reboot to resolve and consider the new values.

Is there a way to resolve %var% in runtime directly from the batch?
Labels (1)
0 Kudos
(2) Replies
alegerlotz
Level 7

dudebigboy wrote:
Let's say I have two installers.

The first one install stuff and create a new environment variable used in the PATH as %var%

The second installer launch a batch file that needs to access the content of the %var%

The problem is that in the second installer, the batch is launched with the new path but unresolved. It still shows as %var%.

If I launch the same installer after a reboot, it correctly resolve the %var% with the specified path I need.

I think this is due to the fact msiexec is used as a service and services in general needs to have a reboot to resolve and consider the new values.

Is there a way to resolve %var% in runtime directly from the batch?



How did you create your environment variable, and add it to the PATH variable? Did you do this through the registry? Are you using InstallScript?

I don't have the info handy, unfortunately, but I do recall that you need to send a message to Windows to get it to "refresh the path" which involves resolving the values within it.

If nobody else has come up with the answer, I can research what I did years ago when I did had this issue. I recall getting a code snipet from somewhere on the internet.
0 Kudos
sandwich
Level 4

// Flush the NT registry to all applications.
szEnv = "Environment";
pEnv = &szEnv;
SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, pEnv );
0 Kudos