I've have wix installer that updates environment variable using <Environment />
element.
The environment variable value is updated in registry. But when I try to open Powershell it doesn't see any changes unless I reboot my PC.
Does anyone have any thoughts about why/how and how can I avoid reboot. Thanks in advance, nomail
Update: I've found why this is happening. It turns out that the session variables are updated on reboot or if a system broadcast message is sent. To send a broadcast message
SendMessage (HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment");
Another dirty way to send a message is to use SETX
command that will write new value to environment variables and update session info
SETX something_that_is_not_important value_that_is_not_important
Mind you that you will still have to close and open CommandLine or PowerShell console
This is almost certainly because of a missing a <WriteEnvironmentStrings>
element in the <InstallExecuteSequence>
section of your WIX file. That custom action is responsible for sending the broadcast WM_SETTINGSCHANGE message.
This isn't exactly a bug in the WIX, rather a poorly documented requirement. To effectively use WIX you also have to understand the Windows Installer Database reference docs, not just the XML. In the MSDN topic on the Environment Table the need to invoke the WriteEnvironmentStrings and RemoveEnvironmentStrings custom actions is described, but in terminology that may be foreign to someone without native MSI background.
An article showing this is at http://blogs.technet.com/b/alexshev/archive/2008/03/28/from-msi-to-wix-part-13-installable-items-environment-variable.aspx
seems to be a specific wix problem, see comments at the bottom of : this page
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With