Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Detect Reboot Required


4 replies to this topic

Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 30 December 2008 - 17:16

Hi All,

As part of a virtual session maintenance tool I am working on, I need to reliably detect when an OS needs a reboot to get itself into a stable state. There are many causes for why a reboot may be needed, and there seems to be many ways to detect whether a reboot is required. Here is what I got so far:
  • There are items listed at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRename
  • There are items listed at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
  • There are items listed at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx
  • There are items listed at HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
  • There are kernel services to be started or filterdrivers to be unloaded (according to AngelD here: http://www.appdeploy...tm.asp?m=39450). Apparently no way to detect this unless the appropriate flags have been raised by whatever installed the services / drivers.

It seems to me that there is a genuine need for a comprehensive "IsRebootReallyNeeded" function that can be used to detect as many of these cases as possible. I can't believe that this hasn't been written a million times before, hence this post...

I am also sure there are other cases when a reboot is needed which is not covered by the above list. Can u think of any such cases? For one thing the newest patches from Microsoft seem to trigger a reboot timer. Any idea where the info for this is stored?
Regards
-Stein Åsmul

VBScab

VBScab
  • Full Members
  • 436 posts

Posted 31 December 2008 - 10:23

My guess would be that there's a Windows message which is passed system-wide, rather like the one which says that there's a new system environment variable. Have a look at the main Windows header file (WINDOWS.H, is it?)

Also, in searching for such a thing (curiousity killed the cat, right?) I came across another key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired

EDIT:
Found this, too.

Edited by VBScab, 31 December 2008 - 10:38.

- Don't know why 'x' happened? Want to know why 'y' happened? ProcMon will tell you.
- Try using http://www.google.com before posting.
- I answer questions only via forums. Please appreciate the time I give here and don't send me personal emails.

Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 04 January 2009 - 00:52

Many thanks mate. Indeed, curiosity killed the cat, and dogs bark up the wrong tree - so we tend to end up with only hair balls in deployment.

Stefan or anyone else know more on this subject? It seems really basic, but it seems to me that there are several conditions that may require a reboot without a uniform way to detect this.
Regards
-Stein Åsmul

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 05 January 2009 - 19:27

Existance of a RunOnce registry entry or even a PendingFileRename entry doesn't necessarily mean that a reboot is required. It might just be some cleanup task for temporary files that was postponed until the next reboot, but doesn't affect other setups at all.
On the other hand, there are so many places where you can set programs to run during startup or login that you can't catch all custom methods - for instance I could put a shortcut in the startup folder of the start menu to do some post-install work.

Windows Installer will set the ReplacedInUseFiles property if a file was locked and a rebbot is required to replace it.

Starting with version 4.0 Windows Installer sets the MsiSystemRebootPending property if a restart of the operating system is currently pending. Not sure how it detects this, maybe there's some API or it checks some of the registry entries you mentioned.

garrote

garrote
  • Full Members
  • 1 posts

Posted 17 April 2009 - 13:49

I know of one way, as I've had to deal with it in the past. The presence of any entry in the HKLM\Software\Microsoft\CurrentVersion\WindowsUpdate\Auto Update\Results with value of 1, will cause the restart pending message to appear when you try new installs, assuming of course that the installer checks there. Generally, you don't see values there with a 0 value, as the entries are deleted after the reboot.

It would seem to me that there would be a better way, but that has worked for me.

Good luck,
Garrote