IBM developerWorks
 
       Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 2 - WMI Programming with Visual Basic.NET: Man...
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 
Moblin 
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: Managing the OS
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2005-07-05

    Table of Contents:
  • WMI Programming with Visual Basic.NET: Managing the OS
  • Retrieving the list of all services
  • How to know the state of a service
  • How to modify (manage) the state of a service
  • How the above program works
  • How will I know the proper description of the error?

  • 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
     
    IBM developerWorks
     
    ADVERTISEMENT

    Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!

    WMI Programming with Visual Basic.NET: Managing the OS - Retrieving the list of all services


    (Page 2 of 6 )

    Since I wanted to implement the theory stated in the previous section, I am considering an example for controlling the list of services through WMI. So, before going into the “real” controlling of services, first of all, we need to display the list of all services to the user so that he can select a service and control it. The following code fragment fetches all the services of OS and adds them to the list box.

    Me.lstServices.Items.Clear()

           DimsearcherAsNewManagementObjectSearcher("SELECT * FROM Win32_service ")

           DimoItemsAsManagementObjectCollection = searcher.Get()

           DimoItemAsManagementObject

           ForEachoItemInoItems

               Me.lstServices.Items.Add(oItem("DisplayName"))

           Next

    I don’t want to get into the details of the above fragment, because it was very clearly explained in the previous part of this series (part 2).  But, make sure that we are trying to fetch all the services from the WMI class “Win32_Service”.

    When you execute the above code, you should be able to see the list of all services populated into the list box as follows (Fig 1):

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


     

    VISUAL BASIC.NET ARTICLES

    - Movement and Player Statistics in a VB.NET T...
    - 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...





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