' Sort WMI Data with Disconnected Record Set



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
search for scripts

VbsEdit contains all these sample scripts!


Download Now!



Download   Home   Scripts

Copyright © 2001-2024 adersοft