Jack Lee
Jack Lee

Reputation: 363

How to detect windows update status

I want to detect current windows 10 update status programmatically.

I tried wuapi and it works well but there are some problems in wuapi.

First, it takes long time to get update information.

Second, it can not be used at offline.

Is there any other method to detect current windows 10 update status? Is there any registry or system file to detect it?

I tried procmon to analyse but there are too many files and registries linked with windows udpate.

Thank you...

Upvotes: 0

Views: 4652

Answers (2)

Mark Phaedrus
Mark Phaedrus

Reputation: 196

There is no documented way to access the search results that Automatic Updates is using (the results that the Windows Update page in Settings displays).

However, there are two things that might be of use to you:

  • You can use IAutomaticUpdatesResults::LastInstallationSuccessDate to immediately see the last time the computer installed updates successfully. If all you want to know is "Is this PC processing updates successfully?", then this may be all you need.
  • You can use a Windows Update API search to see what updates are needed. Here's a script you can use as a starting point. If you use this script as written, it will go online to find newly-released updates, which isn't what you want in your scenario. But you can set your IUpdateSearcher object's Online property to false before calling Search. Doing that will perform an offline scan, in which WU just re-evaluates the updates it already knows about. This will work offline and will also return faster results.

Upvotes: 1

Safi
Safi

Reputation: 11

"COM API

The COM API is a good way to directly access Windows Update without having to parse logs. Applications of this API range from finding available updates on the computer to installing and uninstalling updates.

You could use the Microsoft.Update.Session class to run an update search and then count the number of updates available to see if there are any updates for the computer.

PowerShell Example:

$updateObject = New-Object -ComObject Microsoft.Update.Session
$updateObject.ClientApplicationID = "Serverfault Example Script"
$updateSearcher = $updateObject.CreateUpdateSearcher()
$searchResults = $updateSearcher.Search("IsInstalled=0")
Write-Host $searchResults.Updates.Count

If the returned result is more than 0 then there are updates for the computer that need to be installed and/or downloaded. You can easily update the powershell script to fit your application.

Just a heads up, it appears that the search function is not async so it would freeze your application while searching. In that case you will want to make it async."


Registry method

enter image description here


Source:

https://serverfault.com/questions/891188/is-it-possible-to-detect-the-windows-update-status-via-registry-to-see-if-the-s

Upvotes: 1

Related Questions