Refresh the PATH at runtime
Posted 24 November 2004 - 13:55
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?
Posted 24 November 2004 - 15:16
(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
"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
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...
Posted 02 December 2004 - 12:29
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
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).