Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check when last check for Windows Updates was performed

How can I check WHEN last check for windows updates was performed - in code (c#/.Net)?

Not WHICH updates are or are not installed, but WHEN last check was performed?

Best of all would be a complete history of when checks for windows updates had been performed, but I can certainly live with only knowing the last check.

like image 298
Kjensen Avatar asked Feb 09 '12 17:02

Kjensen


People also ask

How can I tell when Windows updates were last installed?

Select Start > Settings > Update & Security > Windows Update , and then select Check for updates.

When was the most recent Windows 10 Update?

Windows 10 current version information This feature update is known as the “November 2021 Update,” it's been available since November 16, 2021, and the latest quality update is “build 19044.2006.” You can use these instructions to check the version installed on your device.


2 Answers

Look at this registry key:

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

It has 3 sub keys that each provide different information about the different events

  • Detect
  • Download
  • Install

Each key has a LastSuccessTime value you can use.

like image 71
John Koerner Avatar answered Sep 22 '22 01:09

John Koerner


On Windows 7, 8, 10 you can use following code:

var auc = new AutomaticUpdatesClass();

DateTime? lastInstallationSuccessDateUtc = null;
if (auc.Results.LastInstallationSuccessDate is DateTime)
    lastInstallationSuccessDateUtc = new DateTime(((DateTime)auc.Results.LastInstallationSuccessDate).Ticks, DateTimeKind.Utc);

 DateTime? lastSearchSuccessDateUtc = null;
 if (auc.Results.LastSearchSuccessDate is DateTime)
     lastSearchSuccessDateUtc = new DateTime(((DateTime)auc.Results.LastSearchSuccessDate).Ticks, DateTimeKind.Utc);
  • Reference "C:\Windows\System32\wuapi.dll".
  • Check whether EmbeddedInteropTypes on reference is set to False.
like image 35
user2126375 Avatar answered Sep 21 '22 01:09

user2126375