Hi,
My setup program changes the path, and then tries to register DLLs that depend on that new path (for dependant-on DLLs).
When the setup is executed, the path variable gets updated OK (can open a CMD window and see it was changes), but the running instance of the setup still sees the old path, hence the registration of the DLLs fails.
If I restart the setup program, everything is fine, because the path was already updated.
Any idea how I can make setup see the new path without restarting it?
Many thanks,
Gonen
This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.

Refresh the PATH at runtime
Started by
Gonen
, Nov 24 2004 13:55
5 replies to this topic
Posted 24 November 2004 - 15:16
I believe if you override value for environment variable named path with new value
(i assume because you say that after reboot computer you can see new path value).
It must be with a new value for every child-process, hence it truly for installation.
(i assume because you say that after reboot computer you can see new path value).
It must be with a new value for every child-process, hence it truly for installation.
Posted 24 November 2004 - 15:51
if you want to make your application take into account the new value of your environment variable, here is a hint from MSDN:
"Calling SetEnvironmentVariable has no effect on the system environment variables. The user can add or modify system environment variables using the Control Panel. To programmatically add or modify system environment variables, add them to the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment registry key, then broadcast a WM_SETTINGCHANGE message. This allows applications, such as the shell, to pick up your updates."
So try this:
SendMessage( HWND_BROADCAST,WM_SETTINGCHANGE, NULL,NULL);
"Calling SetEnvironmentVariable has no effect on the system environment variables. The user can add or modify system environment variables using the Control Panel. To programmatically add or modify system environment variables, add them to the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment registry key, then broadcast a WM_SETTINGCHANGE message. This allows applications, such as the shell, to pick up your updates."
So try this:
SendMessage( HWND_BROADCAST,WM_SETTINGCHANGE, NULL,NULL);
Posted 24 November 2004 - 16:36
Cooki,
I am already refreshing the environment (maybe with the wrong vars) -
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, pParam, SMTO_ABORTIFHUNG, 100, pResult)
This affects all new windows and applications, but not the already-running-setup-program...
Thanks
Gonen
I am already refreshing the environment (maybe with the wrong vars) -
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, pParam, SMTO_ABORTIFHUNG, 100, pResult)
This affects all new windows and applications, but not the already-running-setup-program...
Thanks
Gonen
Posted 02 December 2004 - 12:29
I believe that you need to modify your setup exe so that it can listen for such a message and update its own environment if it receives such a message. The call doesn't work for any process that is not programmed to accept it and update based on it.
Or just update you setup's environment internally, don't ask me about that though since I'm sure how to do that from within an exe.
Or just update you setup's environment internally, don't ask me about that though since I'm sure how to do that from within an exe.
Posted 02 December 2004 - 12:54
Felix,
Here is an update, in hope it will help others.
1. I followed instructions from an InstallShield article, for properly setting env. vars:
HOWTO: Setting Environment Variables Under Windows NT.
2. Following an advice from the above article, we decided to terminate the installation after the path is updated, asking the user to restart the installation.
Depending on the Win-OS, you may need to restart the PC before continuing the installation.
3. We are about to upgrade to InstallShield 10, hoping to solve this without restarting the installation (currently working with v6.1).
Cheers
Gonen
Here is an update, in hope it will help others.
1. I followed instructions from an InstallShield article, for properly setting env. vars:
HOWTO: Setting Environment Variables Under Windows NT.
2. Following an advice from the above article, we decided to terminate the installation after the path is updated, asking the user to restart the installation.
Depending on the Win-OS, you may need to restart the PC before continuing the installation.
3. We are about to upgrade to InstallShield 10, hoping to solve this without restarting the installation (currently working with v6.1).
Cheers
Gonen