Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 2 - 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 
Actuate Whitepapers 
VeriSign Whitepapers 
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 / 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
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    WMI Programming with Visual Basic.NET: What is the WQL? - Querying WMI with WQL (remote environment)


    (Page 2 of 4 )

    The first article of the series introduced the concept of remote connectivity through WMI. If you really don’t have any idea about remote connectivity through WMI, I suggest you read it. The same concept is being implemented here, but with a mixture of WQL in between!

    Let us consider the following program:

      DimoptionsAsNewConnectionOptions

            options.Username = "administrator"

            options.Password = ""

           DimscopeAsNewManagementScope("\\hostname\root\cimv2", options)

           DimsearcherAsNewManagementObjectSearcher(scope,NewSelectQuery("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 the “form2.vb” file in the zip included for download. The above program is just the combination of the previous section and the last section from the first article. The only new issue is the following statement:

    DimsearcherAsNewManagementObjectSearcher(scope,NewSelectQuery("SELECT * FROM Win32_LogicalDisk"))

    In the previous section, we just issued the SELECT statement in the form of a string. But in the above statement, I created an object of class “SelectQuery” to pass the SELECT query. When scope is provided exclusively, the object of “SelectQuery” is necessary, as the “ManagementObjectSearcher” constructor is expecting an object of type “ObjectQuery”.  In the previous section, the scope defaults to “root\cimv2” of the local server (or system). Apart from the above statement, the rest is the same.

    Make sure that you change the “hostname” in the above program, according to your needs.  Similarly, provide your own credentials of username and password to connect the host.

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


     

    VISUAL BASIC.NET ARTICLES

    - Creating and Drawing a Game Map in VB.NET
    - 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 ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...
    - Programmatically Controlling Windows Fax Ser...





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