none
How to wait for Windows update to be finished on reboot remotely RRS feed

  • Question

  • Hi

    I have a need to reboot a server remotely after installing some Windows updates through WinRM and wait for it to come back online. In a normal scenario this is fine as I wait for the port to go offline then wait for it to come back online but when installing updates it may reboot multiple times during the configuration stage. During this phase WinRM is usually available but when my process moves onto the next task the host may reboot after configuring an update.

    Is there a process/file/flag/api I can use to determine whether Windows is still configuring updates or whether it is sitting on the logon screen and is ready for use?

    Thanks

    Jordan

    Tuesday, August 29, 2017 4:54 AM

All replies

  • Hi Jordan,

    >> Is there a process/file/flag/api I can use to determine whether Windows is still configuring updates or whether it is sitting on the logon screen and is ready for use?

    For this requirement, I think you could try WUApiLib, and I suggest you refer below links.

    # How to know if windows update is waitng for installation [duplicate]

    https://stackoverflow.com/questions/12911218/how-to-know-if-windows-update-is-waitng-for-installation

    # Retrieve Windows Update history using WUAPILib from a remote machine

    https://stackoverflow.com/questions/15786294/retrieve-windows-update-history-using-wuapilib-from-a-remote-machine

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, August 30, 2017 2:51 AM
  • Hi Edward

    Thanks for the reply, I have already solved the issue of installing the updates remotely and rebooting if it is required. My main issue is when Windows installs a bunch of updates and I go to reboot, the following happens

    1. Windows starts to configure some updates (WinRM still active)

    2. Windows performs the reboot (WinRM goes down)

    3. Windows comes back up and continues to configure some updates (WinRM comes back up)

    4. Windows may need to reboot one more time after configuring updates (WinRM goes back down again)

    5. Windows comes back up and the logon screen is now available (WinRM comes back up)

    The trouble is with the 4th step and because all this is happening remotely the reboot checks if the WinRM port is back online before continuing. If Windows needs to reboot that 2nd time my process will fail as the WinRM connection is dropped.

    What I am ultimately after is for some way I can query whether Windows is showing the Logon screen and all pending updates have been configured. That way Windows can reboot as many times and my script does not continue until it is finally finished.

    Is there a way that we can query whether the logon screen is active or whether Windows is still configuring updates after a reboot without manually looking at the console to see where it is at?

    Thanks

    Jordan

    Tuesday, September 5, 2017 8:48 AM
  • Hi Jordan,

    >> Is there a way that we can query whether the logon screen is active

    Not sure whether below link meets your requirement.

    # Ways to check if user is active on remote machine before RDP'ing

    https://superuser.com/questions/313390/ways-to-check-if-user-is-active-on-remote-machine-before-rdping

    >> whether Windows is still configuring updates after a reboot without manually looking at the console to see where it is at?

    My previous reply shares how to query pending updates instead of installing or rebooting, do you mean it did not meet your requirement?

    As far as I know, WUApiLib is the only option to deal with Window updates, if it did not meet your requirement, I am afraid it is impossible for your requirement.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, September 6, 2017 2:59 AM
  • I'll need to see what the results are when running qwinsta in this particular situation. I'm currently trying to build a reproducible image so that I don't need to wait an hour for a server to be ready to test this.

    There is a similar question for this here https://serverfault.com/questions/750885/how-to-remotely-detect-windows-has-completed-patch-configuration-after-reboot but the accepted responses focus on when Windows has installed the updates and is ready to reboot where I am looking at finding out when Windows has finished configured updates during the reboot phase.

    Some of the things I have tried so far but do not work

    * Check if LogonUI.exe was running during the configuration stage but the process is running even during this configurations are

    * Add a reg entry to the RunOnce key to create a file I monitor but this is only run when a user logs in

    I am currently using WUApiLib to install the actual updates and determine if a reboot is required at the end of the install but my issue is around the reboot phase where Windows does the final configuration steps.

    So far from what I can see these are the options that may work out but I need to test further/get help from yourself or someone in MS

    * Find out (from MS) if there is some registry key, file that is set during this reboot configuration page

    * Find out (from MS) if any particular process runs only during this phase and I can query if that is active to determine if Windows is still configuring updates.

    * Some call I can make to WMI/WUApiLib or other library that tells me if Windows is in this phase.

    * Potentially setup a scheduled task to run at boot to create some file I am monitoring to determine if the updates have finished configuring, will need to test this out and see when the task runs (before or after the updates are configured)

    Some more background info for this https://github.com/ansible/ansible/issues/28389, this is a user that is coming across this specific error and I am trying to find a solution to it.


    • Edited by jborean93 Sunday, September 10, 2017 11:37 PM better formatting
    Sunday, September 10, 2017 11:37 PM
  • Hi jborean93,  

    As far as I know, WUApiLib  is the only option to interop with Windows update, and there is no way to determine whether Windows does the final configuration steps. 

    Best Regards,

    Edward



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, September 12, 2017 7:49 AM