A list of every update and hotfix that has been installed on my computer, coming from either Microsoft Windows Update or from the knowledge base. I need the ID of each in the form of KBxxxxxx or some similar representation...
Currently I have:
const string query = "SELECT HotFixID FROM Win32_QuickFixEngineering";
var search = new ManagementObjectSearcher(query);
var collection = search.Get();
foreach (ManagementObject quickFix in collection)
Console.WriteLine(quickFix["HotFixID"].ToString());
But this does not seem to list everything, it only lists QFE's.
I need it to work on Windows XP, Vista and 7.
After some further search on what I've found earlier. (Yes, the same as VolkerK suggests first)
Using the following code I can get a list from which I can extract the KB numbers:
var updateSession = new UpdateSession();
var updateSearcher = updateSession.CreateUpdateSearcher();
var count = updateSearcher.GetTotalHistoryCount();
var history = updateSearcher.QueryHistory(0, count);
for (int i = 0; i < count; ++i)
Console.WriteLine(history[i].Title);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With