Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WIX Detect Pending Reboot

Tags:

wix

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.

like image 767
spfursich Avatar asked Aug 16 '13 23:08

spfursich


2 Answers

Use the RebootPending Burn variable like so

Bootstrapper.Engine.StringVariables["RebootPending"];

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

like image 154
Chris Avatar answered Nov 09 '22 05:11

Chris


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.

like image 25
spfursich Avatar answered Nov 09 '22 06:11

spfursich