WIX Detect Pending Reboot

2019-04-08 11:23发布

I'm using a custom BA with WiX and I'd like to detect if there is a pending reboot to warn my user before they try to install, only to have it fail. How do I reference the Reboot Pending Property in Burn (WiX) That question only showed me what doesn't work, and the OP marked an answer so no one has answered his followup question of, "Having been informed that the RebootPending property inside Burn may not correspond exactly to the property that Windows Installer uses, how else would I ensure that my application does not attempt to install when a reboot is pending?" That is what I'd like to know.

标签: wix
2条回答
Root(大扎)
2楼-- · 2019-04-08 11:39

Use the RebootPending Burn variable like so

Bootstrapper.Engine.StringVariables["RebootPending"];

If it's "1" then a reboot is pending

查看更多
We Are One
3楼-- · 2019-04-08 11:40

Since I'm using a managed installer bootstrapper application I ended up doing this in C# using:

string regLoc = @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager";
string[] regKey = (string[])Registry.GetValue(regLoc, "PendingFileRenameOperations", new string[]{"DefaultValue"});

Entries in that key are files waiting for a reboot so they can be changed. Although this isn't bulletproof, it gives a likely indicator that the install might fail because of a pending reboot.

查看更多
登录 后发表回答