' Sort WMI Data with Bubble Sort
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
For i = (UBound(arrNames) - 1) to 0 Step -1
For j = 0 to i
If UCase(arrNames(j)) > UCase(arrNames(j + 1)) Then
strHolder = arrNames(j + 1)
arrNames(j + 1) = arrNames(j)
arrNames(j) = strHolder
End If
Next
Next
For Each strName in arrNames
Wscript.Echo strName
Next