📊 VBA (Excel)
Export Startup Programs to CSV via WMI (VBA)
Queries Win32_StartupCommand via WMI and writes every Startup Programs row straight to a CSV file in Documents, using plain VBA file I/O.
StartupCommandWmiExport.bas
Attribute VB_Name = "StartupCommandWmiExport"
Option Explicit
Public Sub StartupCommandWmiExport()
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\StartupCommandExport.csv"
propsArr = Split("Name, Command, Location, User", ", ")
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT Name, Command, Location, User FROM Win32_StartupCommand")
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 & " Startup Programs row(s) exported to " & outPath, vbInformation
End Sub