Check when last check for Windows Updates was performed
-
28-04-2021 - |
Question
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.
La solution
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.
Autres conseils
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.
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.