7

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.

Kjensen
  • 12,447
  • 36
  • 109
  • 171

3 Answers3

12

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.

John Koerner
  • 37,428
  • 8
  • 84
  • 134
  • 9
    I do not have a `Results` key in `AutoUpdate` on Windows 10. – IronManMark20 Jan 07 '16 at 01:28
  • I'm not sure if that information is correct, I checked on my system and I have updates installed after the value I found on the 'Install' subkey. I have Windows 7. So at least for me is not reliable. – mjsr Oct 19 '16 at 20:28
10

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.
user2126375
  • 1,594
  • 12
  • 29
-7

In Windows 7, go to Control Panel, System and Security, Windows Update. There is an option to see a history of all the updates, which gives time and date of each.

Guest
  • 1