Posted: Tue Mar 10, 2009 11:42 pm
Sucess !!!! (Thanks to Kiffi and srod with that one little critical piece this morning - the UpdateSearcher\GetObjectProperty("Search('IsInstalled=1 and Type=$0027Software$0027'")") part - Thanks
)
It works here on Vista SP1 and should work on XP also (with the latest Windows Update client installed). This only gets the updates that have been installed by Windows Update on the computer already, and gets the updates that are available on Windows Update presently. Uses the Windows Update API (http://msdn.microsoft.com/en-us/library ... S.85).aspx) and of course COMate.
NOTE: The only difference between the above two procedures is the 'IsInstalled=' value. 'IsInstalled=0 is for getting updates available on Windows Update and 'IsInstalled=1 is for getting updates that have been installed on the computer thru Windows Update. You could do away with one procedure and just have a 1 or 0 sent to to the procedure when you call it > Updates_Machine_infox(winupdate_local.i). I just did it this way because i'm using them in different places for dedicated purposes for expansion later.
In addition, to get updates and hot fixes that have been installed manually (not thru Windows Update), I got some code for that too that i posted previously but here it is again:
(Note: the Win32_QuickFixEngineering class does not get updates installed thru Windows Updates)

It works here on Vista SP1 and should work on XP also (with the latest Windows Update client installed). This only gets the updates that have been installed by Windows Update on the computer already, and gets the updates that are available on Windows Update presently. Uses the Windows Update API (http://msdn.microsoft.com/en-us/library ... S.85).aspx) and of course COMate.
Code: Select all
Procedure Updates_OnLocal_Machine_infox() ; gets updates that have been installed on computer by Windows Update
Protected updateSession.COMateObject
Protected updateSearcher.COMateObject
Protected SearchResult.COMateObject
Protected update.COMateObject
Protected objUpdates.COMateObject
Protected objItem.COMateObject
updateSession = COMate_CreateObject("Microsoft.Update.Session")
updateSearcher = updateSession\GetObjectProperty("CreateupdateSearcher()")
Debug "Searching for updates from Windows Update already installed on computer..." + #CRLF$
SearchResult = UpdateSearcher\GetObjectProperty("Search('IsInstalled=1 and Type=$0027Software$0027')")
objUpdates = searchResult\GetObjectProperty("Updates()")
count = objUpdates\GetIntegerProperty("Count()") - 1
For I = 0 To count
update = searchResult\GetObjectProperty("Updates()")
objItem = update\GetObjectProperty("Item('" + Str(I) + "')")
Debug Str(I + 1) + " >>> " + objItem\GetStringProperty("Title")
Next
EndProcedure
Procedure Updates_Avail_WinUpdate_info() ; gets updates available on Windows Update
Protected updateSession.COMateObject
Protected updateSearcher.COMateObject
Protected SearchResult.COMateObject
Protected update.COMateObject
Protected objUpdates.COMateObject
Protected objItem.COMateObject
updateSession = COMate_CreateObject("Microsoft.Update.Session")
updateSearcher = updateSession\GetObjectProperty("CreateupdateSearcher()")
Debug "Searching for updates avaliable from Windows Update..." + #CRLF$
SearchResult = UpdateSearcher\GetObjectProperty("Search('IsInstalled=0 and Type=$0027Software$0027')")
objUpdates = searchResult\GetObjectProperty("Updates()")
count = objUpdates\GetIntegerProperty("Count()") - 1
For I = 0 To count
update = searchResult\GetObjectProperty("Updates()")
objItem = update\GetObjectProperty("Item('" + Str(I) + "')")
Debug Str(I + 1) + " >>> " + objItem\GetStringProperty("Title")
Next
EndProcedure
In addition, to get updates and hot fixes that have been installed manually (not thru Windows Update), I got some code for that too that i posted previously but here it is again:
(Note: the Win32_QuickFixEngineering class does not get updates installed thru Windows Updates)
Code: Select all
Procedure QFE_Info()
Define.COMateObject objWMIService, QFEInfo
colQFEInfo.COMateEnumObject
strComputer.s = "."
objWMIService = COMate_GetObject("winmgmts:\\" + strComputer + "\root\cimv2", "")
If objWMIService
colQFEInfo = objWMIService\CreateEnumeration("ExecQuery('Select * from Win32_QuickFixEngineering')")
If colQFEInfo
QFEInfo = colQFEInfo\GetNextObject()
While QFEInfo
x = x + 1
id$ = Str(x)
QFE_Caption$ = QFEInfo\GetStringProperty("Caption")
QFE_Name$ = QFEInfo\GetStringProperty("Name")
QFE_Description$ = QFEInfo\GetStringProperty("Description")
QFE_FixComments$ = QFEInfo\GetStringProperty("FixComments")
QFE_HotFixID$ = QFEInfo\GetStringProperty("HotFixID")
QFE_ServicePackInEffect$ = QFEInfo\GetStringProperty("ServicePackInEffect")
QFE_InstallDate$ = UTCDateToDateString(QFEInfo\GetStringProperty("InstallDate"), 0)
QFE_InstalledBy$ = QFEInfo\GetStringProperty("InstalledBy")
Debug id$ + " Caption = " + " " + QFE_Caption$
Debug id$ + " Name = " + " " + QFE_Name$
Debug id$ + " Description = " + " " + QFE_Description$
Debug id$ + " Fix Comments = " + " " + QFE_FixComments$
Debug id$ + " Hot Fix ID = " + " " + QFE_HotFixID$
Debug id$ + " Install Date = " + " " + QFE_InstallDate$
Debug id$ + " Installed By = " + " " + QFE_InstalledBy$
Debug id$ + " Service Pack In Effect = " + " " + QFE_ServicePackInEffect$
If QFE_HotFixID$ = "{1DCBF7A7-7735-433B-BAB6-D0194490A38C}"
Debug id$ + " Special Note = " + " This item is associated with Microsoft Silverlight or other MicroSoft products"
EndIf
Debug "========================"
QFEInfo\Release()
QFEInfo = colQFEInfo\GetNextObject()
Wend
colQFEInfo\Release()
EndIf
objWMIService\Release()
Else
MessageRequester("Error", "QFEInfo")
EndIf
EndProcedure