Visual Basic.NET
  Home arrow Visual Basic.NET arrow 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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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 / 8
    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?


    (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

    - User-defined Functions using Visual Basic Ap...
    - Understanding Object Binding in VBA
    - Mastering the Message Box
    - Testing a Windows Forms Application
    - Using Visual Basic.NET Features to Code a Wi...
    - Correcting Code in a Windows Forms Applicati...
    - Write Readable Code and Comments for Windows...
    - How to Code and Test a Windows Forms Applica...
    - Adding Features to a Windows Forms Applicati...
    - How to Design a Windows Forms Application
    - LINQ to XML Programming Using Visual Basic.N...
    - Understanding Delegates using Visual Basic.N...
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek