How do I get a list of installed updates and hotfixes?

After some further search on what I’ve found earlier. (Yes, the same as VolkerK suggests first)

  1. Under VS2008 CMD in %SystemRoot%\System32\ run a command to get a managed dll:
    tlbimp.exe wuapi.dll /out=WUApiInterop.dll
  2. Add WUApiInterop.dll as a project reference so we see the functions.

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);

Leave a Comment