SunQuest
 
       Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 5 - Managing Windows Indexing Service with Vis...
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

Managing Windows Indexing Service with Visual Basic.NET using WMI
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 10
    2005-10-19

    Table of Contents:
  • Managing Windows Indexing Service with Visual Basic.NET using WMI
  • How to work with/manage Indexing Service
  • Getting "Indexing service" information with WMI and VB. NET
  • Getting a few other properties of "Indexing service" with WMI and VB. NET
  • Managing "Indexing service" with WMI and VB. NET
  • Passing input parameters to WMI for managing Indexing Service

  • 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

    Managing Windows Indexing Service with Visual Basic.NET using WMI - Managing "Indexing service" with WMI and VB. NET


    (Page 5 of 6 )

    Until now, in previous sections, I simply explained how you could retrieve information from an "indexing service". Now we shall "manage" the "indexing service".

    The following code starts the indexing service:

    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e
    As System.EventArgs) Handles btnStart.Click
            Dim LateBoundObject As ManagementObject
            LateBoundObject = New ManagementObject(Nothing, New
    ManagementPath
    ("\\SERVER\root\CIMV2:Win32_Service.Name=""CiSvc"""), Nothing)
            Dim inParams As System.Management.ManagementBaseObject =
    Nothing
            Dim outParams As System.Management.ManagementBaseObject =
    LateBoundObject.InvokeMethod("StartService", inParams, Nothing)
            MessageBox.Show(outParams.Properties
    ("ReturnValue").Value.ToString)
            LateBoundObject.Dispose()
       End Sub

    The above code features a few new declarations, especially "inParams" and "outParams". When we need to pass some information to a WMI method (of a WMI class), we pass it using an object related to "ManagementBaseObject" (in this case "inParams"). The WMI method may return some information back to our application, which will again be a "ManagementBaseObject" (in this case "outParams"). We execute the WMI method using the "InvokeMethod" method available in the "ManagementObject" class.

    From the above code, we need to understand that I received no input parameters to supply for the WMI method "StartService" (and thus it is "nothing"). Once the WMI method "StartService" is executed through "InvokeMethod", the result may be available in "outParams". And we retrieve the "ReturnValue" using same property available in "outParams".

    Let us go through a few other lines of coding available. The following line (if replaced) stops the indexing service.

    Dim outParams As System.Management.ManagementBaseObject =
    LateBoundObject.InvokeMethod("StopService", inParams, Nothing)

    The following line (if replaced) pauses the indexing service.

    Dim outParams As System.Management.ManagementBaseObject =
    LateBoundObject.InvokeMethod("PauseService", inParams, Nothing)

    The following line (if replaced) resumes the indexing service.

    Dim outParams As System.Management.ManagementBaseObject =
    LateBoundObject.InvokeMethod("ResumeService", inParams, Nothing)

    So you can see how easy it is to work with WMI methods.

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · Hello guys...you can now manage indexing service dynamically...just go through the...
     

    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 5 hosted by Hostway