Sorts data returned by a WMI query using a disconnected record set. The value of the variable strClass can be the name of any WMI class that has a Name property.

Visual Basic
Edit|Remove
Dim arrNames()
intSize = 0
strComputer = "."
strClass = "Win32_Process" 'Can use Win32_Service or Win32_Directory
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from " & strClass)

For Each objItem in colItems
  ReDim Preserve arrNames(intSize)
  arrNames(intSize) = objItem.Name
  intSize = intSize + 1
Next

Const adVarChar = 200' Set the data type to variant.
Const MaxCharacters = 200
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "Name", adVarChar, MaxCharacters
DataList.Open
For Each strName In arrNames
  DataList.AddNew
  DataList("Name") = strName
  DataList.Update
Next
DataList.Sort = "Name"
DataList.MoveFirst
Do Until DataList.EOF
  Wscript.Echo DataList.Fields.Item("Name")
  DataList.MoveNext
Loop
DataList.Close