'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalSCRIPT(TM)
'
' NAME: <listWmiClasses.vbs>
'
' AUTHOR: Ed Wilson , MS
' DATE  : 4/17/2006
'ver. 1.2. Cleaned up code, added comments, and renamed some variables.
' COMMENT: <Lists all classes in wmi namespace>
'1.Displays the class name associated with an SWbemPath object
'==========================================================================
Option Explicit
Dim strcomputer 	'target computer
Dim wmiNS					'wmi namespace
Dim objwmiService	'SwbemServices object. The connection into WMI
Dim colClasses 		'sWbemObject set object. A collection of items
Dim objClass			'sWbemObject. An item in colClasses
Dim strOUT				'output of all items
strComputer = "."
wmiNS = "\root\cimv2" 'must precede namespace with \

Set objwmiService = _
    GetObject("winmgmts:\\" & strComputer & wmiNS)
Set colClasses = objwmiService.SubclassesOf()

For Each objClass In colClasses
    strOUT = strOUT &  objClass.Path_.class & vbcrlf
Next

WScript.Echo funline("There are " & colClasses.count  & " classes" &_
	" in the " & wmiNS & " namespace")
WScript.Echo strOUT

' *** function below ***
Function funline(strIn)
funline = Len(strIN)+1
funline = strIN & VbCrLf & String(funLine,"=")
End Function
