I am querying a server's WMI to find all the printers installed locally on it. This query returns all the printers, which I want:
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinter = objWMIService.ExecQuery("Select * from Win32_Printer")
For Each objPrinter in colPrinter
msgbox objPrinter.caption
Next
However I want them in order of the printer name, so I tried putting in the query "Select * from Win32_Printer order by Caption" but this gave an error code 80041017 which suggests the caption field is null. Anyone know how to sort a WMI query?
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinter = objWMIService.ExecQuery("Select * from Win32_Printer")
For Each objPrinter in colPrinter
msgbox objPrinter.caption
Next
However I want them in order of the printer name, so I tried putting in the query "Select * from Win32_Printer order by Caption" but this gave an error code 80041017 which suggests the caption field is null. Anyone know how to sort a WMI query?