Click here to Skip to main content
15,891,764 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have this code which return all installed updates on windows. But problem is if I uninstall few updates this still returns those updates. i want only those updates which are currently installed.

Dim oWU As New WUApiLib.UpdateSearcher
           Dim colUpdate As WUApiLib.IUpdateHistoryEntryCollection
           Dim iTHCount As Integer
           Dim oUpdate As WUApiLib.IUpdateHistoryEntry

           iTHCount = oWU.GetTotalHistoryCount
           If iTHCount > 0 Then
              colUpdate = oWU.QueryHistory(0, iTHCount)
               For Each oUpdate In colUpdate
                   If oUpdate.ResultCode = 2 Then ' only succeeded updates
                       console.writeline(oUpdate.Title.ToString.Trim.ToLower)
                       dtUpdates.Rows.Add(dr)
                   End If
               Next
           End If


[Edit]Removed 'C#' tag[/Edit]
Posted
Updated 28-Oct-13 1:23am
v2
Comments
ledtech3 28-Oct-13 11:29am    
After testing your code and watching what it does it appears that all it does is parse the Update log file located at.
C:\Users\UserName\AppData\Local\Microsoft\Windows\WindowsUpdate.log

So you may need to find out if there is a result code for removed updates in order not to display them.

Edit:
I found the page that list the result codes but Uninstall is not listed there.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa387095(v=vs.85).aspx
Member 12357066 18-Oct-19 14:26pm    
Wie kann ich eine Installation veranlassen ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900