📊 VBA (Excel)
Export Installed Hotfixes to CSV via WMI (VBA)
Queries Win32_QuickFixEngineering via WMI and writes every Installed Hotfixes row straight to a CSV file in Documents, using plain VBA file I/O.
QuickFixEngineeringWmiExport.bas
Attribute VB_Name = "QuickFixEngineeringWmiExport"
Option Explicit
Public Sub QuickFixEngineeringWmiExport()
Dim objWMIService As Object
Dim colItems As Object
Dim objItem As Object
Dim outPath As String
Dim fileNum As Integer
Dim propsArr() As String
Dim c As Long
Dim lineOut As String
Dim val As String
Dim rowCount As Long
outPath = Environ("USERPROFILE") & "\Documents\QuickFixEngineeringExport.csv"
propsArr = Split("HotFixID, Description, InstalledOn, InstalledBy", ", ")
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT HotFixID, Description, InstalledOn, InstalledBy FROM Win32_QuickFixEngineering")
fileNum = FreeFile
Open outPath For Output As #fileNum
Print #fileNum, Join(propsArr, ",")
rowCount = 0
For Each objItem In colItems
lineOut = ""
For c = LBound(propsArr) To UBound(propsArr)
val = ""
On Error Resume Next
val = CStr(objItem.Properties_(propsArr(c)).Value)
On Error GoTo 0
If c > LBound(propsArr) Then lineOut = lineOut & ","
lineOut = lineOut & """" & Replace(val, """", """""") & """"
Next c
Print #fileNum, lineOut
rowCount = rowCount + 1
Next objItem
Close #fileNum
MsgBox rowCount & " Installed Hotfixes row(s) exported to " & outPath, vbInformation
End Sub