Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 4 - WMI Programming with Visual Basic.NET: Wha...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

WMI Programming with Visual Basic.NET: What is the WQL?
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2005-06-28

    Table of Contents:
  • WMI Programming with Visual Basic.NET: What is the WQL?
  • Querying WMI with WQL (remote environment)
  • Types of WQL queries
  • Working with WQL Schema queries

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    WMI Programming with Visual Basic.NET: What is the WQL? - Working with WQL Schema queries


    (Page 4 of 4 )

    As explained in the previous section, schema queries are used to retrieve class definitions. The following simple example lists all of the classes in the WMI environment.

    DimsearcherAsNewManagementObjectSearcher("SELECT * FROM meta_class")

           DimwmiClassAsManagementClass

           ForEachwmiClassInsearcher.Get()

               Me.lstMembers.Items.Add(wmiClass("__CLASS").ToString())

           Next

    Interesting! You will be able to find approximately 800+ classes. So, you can imagine how much information you can gather from WMI. You can observe that the SELECT statement is being used with “meta_class” which works in a way similar to the concept of reflection in .NET. You can obtain the above code from the “form3.vb” file in the zip included for download. 

    Can we get all of the namespaces in the same way as above? Why not? I hope you would be glad to work with that one too. The following shows you how to do it (and can be found at “form4.vb”):

    DimnsClassAsNewManagementClass( _

                         NewManagementScope("root"), _

                         NewManagementPath("__namespace"), _

                          Nothing)

           DimnsAsManagementObject

           ForEachnsInnsClass.GetInstances()

               Me.lstMembers.Items.Add(ns("Name").ToString())

           Next

    Can we get all of the sub-namespaces of a particular namespace? Why not? In the above example, replace “root” with your own known namespace such as “root\cimv2” or “root\Microsoft” or whatever is appropriate. The program automatically retrieves all of the sub-namespaces available within the namespace specified (and can be found at “form5.vb”).

    And finally, the following example gives you the list of all the classes available in a particular namespace (and can be found at “form6.vb”).

           DimsearcherAsNewManagementObjectSearcher( _

                 NewManagementScope("root\" &Me.lstNamespaces.Text), _

                 NewWqlObjectQuery("select * from meta_class"), _

                 Nothing)

           DimwmiClassAsManagementClass

           ForEachwmiClassInsearcher.Get()

               Me.lstClasses.Items.Add(wmiClass("__CLASS").ToString())

           NextwmiClass

    In the above program, you can replace “me.lstnamespaces.text” with any namespace you want. The above program actually tries to list all the classes of the namespace selected in the ‘lstNamespaces’ control.

    Using all of the examples in this section, together with some investigation of System.Management classes, you can also design WMI object explorer (both for local and remote) completely by yourself. The object explorer could either be windows based or Web based (following the strategy of WBEM). But, it needs some indepth study of certain classes within the same namespace. I leave it to the readers to further investigate and research the System.Management namespace.

    For a complete list of all namespaces and classes, I suggest you refer to MSDN or WMI SDK. The WMI SDK documentation contains all the namespaces and classes, beautifully organized based on the categories. All of the members of each and every class present in WMI are thoroughly discussed within the WMI SDK.

    In my upcoming articles, I would like to cover as many examples as possible to get several types of information from WMI. We shall also implement both the Windows and Web styles of interfacing through WMI. The topic of “Event Queries” (discussed above) has to be dealt with indepth. I will present a wonderful example of event consuming through windows service using WMI as part of this series.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    VISUAL BASIC.NET ARTICLES

    - Create a Sudoku Puzzle Generator using VB.NET
    - Entity Creation and Messaging in a VB.NET Te...
    - Movement and Player Statistics in a VB.NET T...
    - Creating and Drawing a Game Map in VB.NET (F...
    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway