WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

User Sample Code

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

List All WMI Classes Properties and Methods

 Keywords: list enumerate WMI win32 class method property 

strComputer = "."
objWMIService=ObjectGet("winmgmts:{impersonationLevel=impersonate}!\\" : strComputer : "\root\cimv2")
filename = 'D:\temp\wmiClasslist.txt'
fh = FileOpen( filename, "Write")
ForEach objclass In objWMIService.SubclassesOf()
   intCounter=0
   If StrSub(objClass.Path_.Class,1,5) == "Win32"
      ForEach Qualifier In objClass.Qualifiers_
         If StrUpper(StrTrim(Qualifier.Name)) == "ASSOCIATION"
             intCounter = 1
         EndIf
      Next
      FileWrite(fh, objClass.Path_.Class); Classname
      strComputer = "."
      objWMIService = ObjectGet("winmgmts:{impersonationLevel=impersonate}!\\" : strComputer : "\root\cimv2")
      strClass = objWMIService.Get(objClass.Path_.Class)
      If strClass.properties_.count > 0
         FileWrite(fh, @TAB:'PROPERTIES')
         ForEach strItem In strClass.properties_
            FileWrite(fh, @TAB:@TAB:strItem.name )
         Next
      EndIf
      If strClass.methods_.count > 0
         FileWrite(fh, @TAB:'METHODS')
         ForEach strItem In strClass.methods_
            FileWrite(fh, @TAB:@TAB:strItem.name )
         Next
      EndIf
   EndIf
Next
FileClose(fh)
Run( filename, "" )

Article ID:   W18484
Filename:   List All WMI Classes Properties and Methods.txt
File Created: 2011:04:27:11:35:04
Last Updated: 2011:04:27:11:35:04