4

Question in short

How to automate with Windows built-ins (batch/PowerShell) or freely available tools, prefereably command-line, following steps:

  1. Scan for all currently available updates on WU
  2. Download and install them right now (i.e. without any throttling/scheduling/backgrounding)
  3. Restart if necessary, closing whatever doesn't closes automatically.

I'd also like something that triggers the same background mechanism behind existing WU in Setting panel, not something that will use separate infrastructure by setting up its own download locations or whatever.

Background

I have a PC that doesn't have regular restarts or fixed working schedule. WU is running, but all its auto-restart facilities are completely disabled so it won't get in the way of the work at some absolutely inconvenient time. Sometimes a window of opportunity comes up when I can dedicate time to running a full cycle of updates. To do it manually I need to:

  1. Open WU settings
  2. Run "Check for updates" to reveal fresh updates missing for any reason
  3. Click "Download" and then wait arbitrary long time, because apparently this only schedules actual download and both download and installation are heavily throttled depending on PC load
  4. Wait until process is done and manually restart PC if necessary - trying to use "Update & Restart" from power menu often only installs already downloaded stuff and skips over what is not downloaded
  5. Restart often reveals previously hidden updates that DO NOT depend on what was just installed - Settings' WU panel just seems to stop displaying new updates after at least one freshly installed requests restart

I'd like to automate all those steps and, if possible, reduce number of restarts.

So far I tried

  1. PSWindowsUpdate 3rd party module for PowerShell, but it seems to display different set of available updates - e.g. it offered me to install Silverlight - and whatever it installs does not appear in "View update history" list.

Example: Settings' WU vs PSWindowsUpdate difference

  1. usoclient.exe looks promising, but there's no official documentation for it and from some online examples of people cobbling up some working scripts, it seems there's no reliable way to detect when all updates are done installing and it is time to reboot.
1

1 Answer 1

0

Windows 10 has implemented a new command for installing updates - usoclient. The previous command WUAUCLT does not work any more.

You will also need a third-party product to shutdown with update and reboot - ShutdownWithUpdates.

Here is how to use it as Administrator:

usoclient ScanInstallWait
usoclient StartInstall

REM Wait 40 mins to allow all the installs to complete
timeout /T 2400

\path\ShutdownWithUpdates.exe /r /f

This method has three problems:

  1. It's unknown how long we need to wait for the updates to install, as 40 minutes is just arbitrary
  2. There is no way of knowing if the installed updates have introduced the need for further updates, so the script needs to be run again one or more times
  3. Too many optional updates may be installed.

References:


The PowerShell method uses the following commands as Administrator:

  • Install Windows Update Module (one time command) : Install-Module PSWindowsUpdate

  • Check and Download the latest updates : Get-WindowsUpdate

  • Install the latest updates : Install-WindowsUpdate

This method also suffers from the above problems number 2 and 3.

4
  • Yes, that's one of examples I've seen and the one that has "no reliable way to detect when all updates are done installing", as mentioned in question. Also ShutdownWithUpdates explicitly documented to only install updates that were completely downloaded, so if some update has long install procedure and blocks downloading of other updates, using arbitrary timer won't let install even those updates that were detected on first run. Commented Mar 7, 2021 at 3:21
  • I have added the PowerShell method. You now have all the possible methods. However both of these "install all" methods are imperfect and cannot replace the interactive Windows Update.
    – harrymc
    Commented Mar 7, 2021 at 10:45
  • 1
    So, you've pretty much listed all the stuff I've mentioned already in "So far I tried" section in question itself and already said it doesn't work quite as I need it to. Commented Mar 7, 2021 at 14:03
  • I have added all the information for using the two known methods, and I have found user-written documentation for usoclient. Please note that Microsoft also uses these methods one way or another, but only in an interactive manner, for a very good reason. I have given all the information required for making it work, as you requested, although I would really prefer you not to use it.
    – harrymc
    Commented Mar 7, 2021 at 14:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .