1

From the Windows Update COM Library (WUAPILib) I have access to the IUpdate interface however I don't see of any way to use to get the update classification (Critical, Important, Optional) to group updates in the same way like the Windows Update UI in Control Panel does.

Paul
  • 42
  • 5
  • 19

1 Answers1

2

With the help of the IUpdate, you can get the IcategoryCollection from the Update ID.

Now, the first ICategory stores the classification of update type for the OS. Do pay special attention to the line where comment is placed:

Console.WriteLine("Patch name = " + ic.Name.ToString());
// In the ICategory collection, first element ICategory stores information of "Update Classification"; 
// whereas second Icategory element stores the product type information.

Test Code:

UpdateSession uSession = new UpdateSession();
IUpdateSearcher uSearcher = uSession.CreateUpdateSearcher();
uSearcher.Online = false;
ISearchResult sResult = uSearcher.Search("IsInstalled=1 And IsHidden=0");
Console.WriteLine("Found " + sResult.Updates.Count + " updates" + Environment.NewLine);
   foreach (IUpdate update in sResult.Updates)
   {
          Console.WriteLine();
          Console.WriteLine("Required update " + update.KBArticleIDs[0].ToString() + " is installed...");
          Console.WriteLine("Update ID = "+update.Identity.UpdateID);
          ICategoryCollection icc = update.Categories;
          foreach (ICategory ic in icc)
          {
            Console.WriteLine("Patch description = " + ic.Description.ToString());
            Console.WriteLine("Patch category = " + ic.CategoryID.ToString());
            Console.WriteLine("Patch Type = " + ic.Type.ToString());
            Console.WriteLine("Patch name = " + ic.Name.ToString()); 
// only first ICategory element stores the patch name,
// which reveals the Classification information
          }
   }

Sample Output:

enter image description here

Am_I_Helpful
  • 18,735
  • 7
  • 49
  • 73
  • Thank you for your reply, I find your reply very helpful. I did look at this as well however how does Microsoft consider an update to be "Important" in their GUI? While I can definitely group them like this, the grouping will be different than the one in the Windows Updates GUI. – Paul Jan 24 '18 at 10:11
  • @Paul - Just refer this: https://blogs.technet.microsoft.com/dubaisec/2016/01/28/windows-update-categories/ ;Takeaway: 1. Critical update is an update which fixes critical non-security related bug. 2. Critical Security Update is an update which fixes critical security vulnerability. 3. Important update is category displayed by Windows Update and include all Security updates regardless of the MCRS severity rating as well as other update categories like Critical Updates, Definition updates etc. 4. Important Security Update is an update which fixes important security vulnerability. – Am_I_Helpful Jan 24 '18 at 10:48
  • @Paul - Continued... You can use this logic in your code to filter out the updates as per the category. I hope it is helpful. – Am_I_Helpful Jan 24 '18 at 10:55
  • 1
    Thanks, the article you've linked answers my question. – Paul Jan 24 '18 at 13:04