Microsoft KB Archive/246204

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 13:49, 21 July 2020 by X010 (talk | contribs) (Text replacement - """ to """)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

HOWTO: Enumerate Windows Management Instrumentation Namespaces

Q246204



The information in this article applies to:


  • Windows Management Instrumentation, versions 1.0, 1.1, 1.5





SUMMARY

You cannot enumerate all the Windows Management Instrumentation (WMI) namespaces on a computer by using a single query in a single namespace.



MORE INFORMATION

In order to enumerate all the namespaces, you must first connect to the "root" namespace, query for all the "__NAMESPACE" instances, and for each instance recursively repeat this process.

The following Microsoft Visual Basic code snippet is a recursive subroutine that enumerates the namespaces under the namespace tree rooted at the namespace specified in the parameter.

Sub PrintNamespaces(namespace As String)

Debug.Print namespace
Set locator = CreateObject("WbemScripting.SWbemLocator")
Set wmi = locator.ConnectServer(".", namespace)
For Each obj In wmi.InstancesOf("__NAMESPACE")
    PrintNamespaces namespace + "\" + obj.Name
Next

End Sub 


To enumerate all of the namespaces on the computer, call the subroutine with "root" as the parameter:

PrintNamespaces "root" 

Additional query words: wmi wbem namespace enumerate

Keywords : kbsms kbWMI100 _IK
Issue type : kbhowto
Technology : kbWMISearch kbAudDeveloper kbWMI100 kbWMI110 kbWMI150


Last Reviewed: February 20, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.