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

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

    - 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...
    - Focusing on Forms and Menus in Visual Basic





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