Monday, February 7, 2011

Programmatically list WMI classes and their properties

Hey everyone, Is there any known way of listing the WMI classes and their properties available for a particular system? Im interested in a vbscript approach, but please suggest anything really :)

P.S. Great site.

  • I should also add that I am not trying to get the values of the properties rather listing the available class and its properties for selection, then retrieving the value. Call it... a class browser, thats what Im calling it ;)

  • I believe this is what you want.

    WMI Code Creator

    A part of this nifty utility allows you to browse namespaces/classes/properties on the local and remote PCs, not to mention generating WMI code in VBScript/C#/VB on the fly. Very useful.

    Also, the source code used to create the utility is included in the download, which could provide a reference if you wanted to create your own browser like interface.

    From Copo
  • This MSDN page walks through enumerating the available classes: How to: List the Classes in a WMI Namespace

    for retrieving properties from a class:

    ManagementPath l_Path = new ManagementPath(l_className);
    ManagementClass l_Class = new ManagementClass(myScope, l_ManagementPath, null);
    foreach (PropertyData l_PropertyData in l_Class.Properties)
    {
        string l_type = l_PropertyData.Type.ToString());
        int l_length = Convert.ToInt32(l_PropertyData.Qualifiers["maxlen"].Value);           
    }
    
    From JustinD
  • Check this page:

    http://technet.microsoft.com/en-us/magazine/cc983775.aspx

    From Shay Levy

0 comments:

Post a Comment