Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 6 - 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 - Passing input parameters to WMI for managing Indexing Service


    (Page 6 of 6 )

    In the previous section, we dealt with some of the WMI methods that don't have any input parameters. But, there will be cases where input parameters are necessary. One of these cases is "changing the start mode" of the indexing service.

    To change the start mode, we need to provide the type of start mode to WMI (which is an input parameter). This input parameter will be gathered by the WMI method; it manages the indexing service accordingly.

    The following script changes/modifies the start mode of indexing service.

    Private Sub btnChangeStartMode_Click(ByVal sender As
    System.Object, ByVal e As System.EventArgs) Handles
    btnChangeStartMode.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
            inParams = LateBoundObject.GetMethodParameters
    ("ChangeStartMode")
            inParams("StartMode") = "Automatic"
            Dim outParams As System.Management.ManagementBaseObject =
    LateBoundObject.InvokeMethod("ChangeStartMode", inParams,
    Nothing)
            MessageBox.Show(outParams.Properties
    ("ReturnValue").Value.ToString)
            LateBoundObject.Dispose()
       End Sub

    You could observe that everything is the same, except for some new lines as follows:

    inParams = LateBoundObject.GetMethodParameters("ChangeStartMode")
    inParams("StartMode") = "Automatic"
    Dim outParams As System.Management.ManagementBaseObject =
    LateBoundObject.InvokeMethod("ChangeStartMode", inParams,
    Nothing)

    From the above statements, we can understand that we are working with the WMI method "ChangeStartMode" which accepts an input parameter called  "StartMode" (which is of type string). First of all, we get all parameters into "inParams" with the help of "getMethodParameters", focussing on "ChangeStartMode" method. Then, we assign values for all those input parameters in the form of properties. Finally we invoke the WMI method using "InvokeMethod".

    Summary

    WMI leads the way to WBEM (Web Based Enterprise Management) in a very easy and pleasant manner. I focussed only on "Indexing Service" in this article, to work with WMI. But you can work with almost any service within Windows OS. Another great point is that WMI is transparent to ASP.NET as well. Try to convert the above application to a web application (ASP.NET). It works without any core changes!  

    One should also note that WMI does not supercede all of the features of every service (or the entire Win32 API). At the same time, WMI is getting enhanced and extended day by day. For example, we cannot work with "catalogs" in an indexing service using WMI. WMI does not support it (though it may be supported in future versions of WMI). To work with "catalogs" of the indexing service, we need to work with COM (you can expect my next article on it soon).

    Any comments, suggestions, bugs, errors, feedback etc. are highly appreciated at jag_chat@yahoo.com.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

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

    VISUAL BASIC.NET ARTICLES

    - Clocks and Countdowns
    - 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...





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