Managing Windows Indexing Service with Visual Basic.NET using WMI - Getting "Indexing service" information with WMI and VB. NET
(Page 3 of 6 )
Can we manage/access "Indexing service" directly from within .NET (natively)? .NET natively doesn't support access to Indexing service. So, we need to extend our .NET application to interact with either WMI or COM to manage/access the "indexing service."
WMI is a good emerging technology from Microsoft for their support to WBEM (Web Based Enterprise Management). For a complete understanding of WMI together with .NET programming, I suggest you go through my series "WMI programming using Visual Basic.NET." Once you are familiar with at least the first two parts in that series, there is no doubt that you will be able to understand this article easily.
The downloadable solution contains a "WinForms" application, which interacts with the "Indexing Service" using pure WMI. It is important to note that you need to add a reference to "System.Management" namespace to your project, when you are working with WMI (and also import it at the top).
Let us go through a small code fragment, which I used to retrieve information from an "Indexing Service."
Private Sub btnCaption_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnCaption.Click
Dim LateBoundObject As ManagementObject
LateBoundObject = New ManagementObject(Nothing, New
ManagementPath
("\\SERVER\root\CIMV2:Win32_Service.Name=""CiSvc"""), Nothing)
MessageBox.Show(CType (LateBoundObject("caption"),
String))
LateBoundObject.Dispose()
End Sub
Within the above code, I am creating a "ManagementObject" (an object related to WMI) and then assigning the path of the indexing service ("CiSvc") object to the "ManagementObject". You can also find/list all the services along with their names using WMI and Visual Basic.NET (which is demonstrated in "WMI programming using Visual Basic.NET" series). For now, we concentrate only on the "indexing service."
The WMI class "Win32_Service" in "root\CIMV2" namespace has a property "caption", which gives the title/caption of that service. To retrieve that, I simply used the property "caption" with the management object created. And finally I disposed the "ManagementObject".
Next: Getting a few other properties of "Indexing service" with WMI and VB. NET >>
More Visual Basic.NET Articles
More By Jagadish Chaterjee