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  
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

Managing Windows Indexing Service with Visual Basic.NET using WMI
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 13
    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


    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

    - 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 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek