How do I reference the Reboot Pending Property in

2019-01-25 21:23发布

问题:

How do I reference the RebootPending property in a Burn (WiX) bootstrapper? I know the property name is RebootPending, which is actually referencing the MsiSystemRebootPending property in Windows Installer.

I'm currently trying something like this:

<bal:Condition Message="There is a restart pending. Please restart your computer before  attempting to install !(loc.ProductName).">RebootPending = 0</bal:Condition>

But it's always true, even when Windows Update has just finished an update and needs to restart.

Is my syntax wrong? Should my condition have [RebootPending] instead?

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?

回答1:

Burn doesn't use MSI's MsiSystemRebootPending because it operates outside an installation transaction. So Burn uses ISystemInformation::RebootRequired instead. There's no guarantee that MSI and ISystemInformation::RebootRequired have the same idea about whether a reboot is required, since MSI doesn't document with MsiSystemRebootPending reflects.



回答2:

For some general ideas see tool WhyReboot. Here is what it does:

Examines documented registry locations for post-reboot file copy/rename/delete operations.

Examines documented registy locations for "Run Once" applications: these will run once on the next reboot, and are probably used by an installer to perform post-reboot file cleanup and other operations such as registry manipulation.

Examines Wininit.ini on Win9x/ME platforms for pending file rename/delete operations.



回答3:

I don't know if it helps but it says here that RebootPending value

will reflect the reboot status of the system when the variable is first requested



回答4:

ISystemInformation::RebootRequired: Somebody asked for some sample code to call ISystemInformation::RebootRequired mentioned in Arnson's answer.

Here is one blurb - not exactly great, but maybe give it a try:

Set autoupdate = CreateObject("Microsoft.Update.AutoUpdate")
autoupdate.Pause()
MsgBox Err.Number & " " & Err.Description

Set sys = CreateObject("Microsoft.Update.SystemInfo")
MsgBox sys.RebootRequired

' autoupdate.Resume() ' Enable to resume AutoUpdate
Set sys = Nothing
Set autoupdate = Nothing

Maybe just use the latter part:

Set sys = CreateObject("Microsoft.Update.SystemInfo")
MsgBox sys.RebootRequired
Set sys = Nothing

I am not really familiar with the Windows Update Agent Object Model.


Reboots: There are many registry locations that can be involved in triggering a reboot (warning). Get-PendingReboot-Query. And a similar PowerShell script.

Here are some registry locations I have found that are involved in Windows rebooting (definitely not exhaustive):

  • HKLM\SOFTWARE\Microsoft\Updates : UpdateExeVolatile
  • HKLM\SYSTEM\CurrentControlSet\Control\Session Manager : PendingFileRenameOperations
  • HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer : InProgress
  • HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing : RebootPending
  • HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update : RebootRequired
  • HKLM\SYSTEM\Setup : SystemSetupInProgress

And computer rename operation in progress:

  • HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName : ComputerName
  • HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName : ComputerName

CCMClientSDK: And then there are some WMI calls to check for SCCM 2012 Client Reboot Pending Status. CCMClientSDK.IsHardRebootPending and CCMClientSDK.RebootPending. Check the Get-PendingReboot-Query script.