0

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...

Jack Lee
  • 363
  • 5
  • 18
  • **What are you really trying to do?** By detecting activity of Windows Update, what are you hoping to do? What is the feature/service you are trying to build? – selbie Nov 25 '19 at 02:55
  • At os setting Windows Update, without connecting the internet, it shows your os is not up-to-date. I want to know this information at registry. – Jack Lee Nov 25 '19 at 03:32

2 Answers2

1

"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

Safi
  • 11
  • 1
  • Thank you for you help but my goal is to how to see Windows Update setting's status. My os is offline but Windows Update Setting windows show your os need to be updated. I think this information is at registry or other system file. – Jack Lee Nov 25 '19 at 03:35
  • I suspect that this information is kept in a private area that Windows Update uses, and you are unlikely to find it in a reasonable way. And this information could have *only* been determined by being online at some point in the past. Are you trying to determine if you need to go online or not, or is there something else you're trying to accomplish? – Steve Friedl Nov 25 '19 at 03:52
  • @SteveFriedl, thank you. I think windows update setting windows shows information even offline, this means in os there is this information but not easy to know. – Jack Lee Nov 25 '19 at 04:12
1

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.