This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Resolving Environment Variable
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 26, 2008
12:26 PM
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?
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?
(2) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 26, 2008
01:31 PM
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 26, 2008
02:06 PM
// Flush the NT registry to all applications.
szEnv = "Environment";
pEnv = &szEnv;
SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, pEnv );
szEnv = "Environment";
pEnv = &szEnv;
SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, pEnv );
![](/skins/images/8C9D13A71C7F7695F3262372C0172D68/responsive_peak/images/icon_anonymous_message.png)