Managing Windows Indexing Service with Visual Basic.NET Using COM - How to change the “start mode” of (or manage) indexing service
(Page 3 of 4 )
“Starting” the indexing service is different and “start mode” is different. “Start mode” is the mode which makes the service “auto start” or “manual start” or even be “disabled.” We can change “Start mode” directly using the “services snap-in” provided by the Microsoft OS. Now we shall see how to change the same dynamically using COM programming together with .NET.
Dim obj As New CIODMLib.AdminIndexServerClass
Private Sub btnConfigure2AutoStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
btnMakeItAutoStart.Click
obj.EnableCI(True)
MessageBox.Show("Made it Autostart")
End Sub
Private Sub btnMakeItManualStart_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnMakeItManualStart.Click
obj.EnableCI(False)
MessageBox.Show("Made it Manual")
End Sub
You can observe that the above code got split into two events, one each for “AutoStart” and “ManualStart.” The “AdminIndexServerClass” mainly contains a method “EnableCI,” which can be used to change the “start mode” of Indexing Service. It accepts a “Boolean” value (true or false). A “true” value makes the Indexing Service “auto-start” and vice versa with “false.”
Now let us see how to change the state of Indexing Service. I would like to “start” or “stop” the indexing service dynamically through programming. Let us see how.
Dim obj As New CIODMLib.AdminIndexServerClass
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnStart.Click
obj.Start()
MessageBox.Show("Service Started ")
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnStop.Click
obj.Stop()
MessageBox.Show("Service Stopped")
End Sub
I don’t think I need to explain anything about the above code. I think you can understand that all of the above code (in this section) is also quite different from that of WMI code in my previous article.
Next: How to program the index catalogs >>
More .NET Articles
More By Jagadish Chaterjee