Visual Basic.NET
  Home arrow Visual Basic.NET arrow WMI Programming with Visual Basic.NET: Wha...
Iron Speed
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 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
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 / 6
    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
     
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    WMI Programming with Visual Basic.NET: What is the WQL?
    (Page 1 of 4 )

    The goal of this series is to introduce Microsoft Windows Management Instrumentation (WMI) and get you up and running as quickly as possible, using it to manage your system through the WMI programming using .NET. This article covers querying WMI with the Windows Query Language.


    You can download the zip of entire Visual Studio.NET solution (developed for this article) here.

    The first part of this series covered the basics of WMI and how to access WMI information from Visual Basic.NET (both locally and remotely). In this article, I will introduce you to the concept of WQL together with types of WQL queries.

    The first article in this series gave you the details for creating a Visual Studio.NET solution for WMI, from scratch. This information will not be repeated in any of the future articles in this series.

    Querying WMI with WQL (local environment)

    Anyone who works in the IT sector would definitely hear about SQL. Structured Query Language (SQL) is a great querying language for relational databases. As SQL is used for relational databases, WQL is used to query WMI information. But, one should consider that it is not as robust as SQL. In this article, I will cover only the basics of WQL rather than going into very great depth at this moment.

    The WMI Query Language (WQL) is a subset of the American National Standards Institute Structured Query Language (ANSI SQL)—with minor semantic changes. We can just consider WQL as something like “WMI + SQL = WQL”.

    The following is a small example which demonstrates a simple SELECT statement in WQL.

    DimsearcherAsNewManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk")

    DimdisksAsManagementObjectCollection = searcher.Get()

    DimdiskAsManagementObject

    DimarDisksAsNewArrayList

    ForEachdiskIndisks

    arDisks.Add(disk("deviceid").ToString())

    Nextdisk

    Me.lstDrives.Items.AddRange(arDisks.ToArray)

     

    You can obtain the above code from “form1.vb” file in the zip file included for download. If you observe the above code and compare it with my previous examples (present in part one), there exists only a small difference, as follows:

    DimsearcherAsNewManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk")

    DimdisksAsManagementObjectCollection = searcher.Get()

    In the first statement, I am using a new class named “ManagementObjectSearcher”, used to retrieve a collection of management objects based on a specified query. The class got a method “get()” to retrieve all instances of objects based on the query specified. And I hope the rest is the same.

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


     

    VISUAL BASIC.NET ARTICLES

    - 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 ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...
    - Focusing on Forms and Menus in Visual Basic
    - Manipulating Forms with the Windows Forms Li...
    - Basics of the Windows Forms Library
    - Forms, Controls, and Other Useful Objects
    - Implementing OOP to Develop Database Oriente...
    - Using Themes and Skins for Personalization w...
    - A Deeper Look at Personalization using Visua...




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