Managing Windows Indexing Service with Visual Basic.NET using WMI - Getting a few other properties of "Indexing service" with WMI and VB. NET
(Page 4 of 6 )
Once you understand the previous section, there is no doubt that you can understand this section very easily. So, let us go through a few more scripts from the sample solution you downloaded.
The following script informs you whether the "indexing service" has been started or not.
Private Sub btnStatus_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnStatus.Click
Dim LateBoundObject As ManagementObject
LateBoundObject = New ManagementObject(Nothing, New
ManagementPath
("\\SERVER\root\CIMV2:Win32_Service.Name=""CiSvc"""), Nothing)
MessageBox.Show(CType(LateBoundObject("Started"),
Boolean))
LateBoundObject.Dispose()
End Sub
The above script is very similar to the one provided in the previous section except that I used the property "Started." The property just returns "Boolean" (whether the service started or not).
The following script informs you of the "start mode" of the "indexing service" (Automatic, Manual or Disabled).
Private Sub btnStartMode_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnStartMode.Click
Dim LateBoundObject As ManagementObject
LateBoundObject = New ManagementObject(Nothing, New
ManagementPath
("\\SERVER\root\CIMV2:Win32_Service.Name=""CiSvc"""), Nothing)
MessageBox.Show(CType(LateBoundObject("StartMode"),
String))
LateBoundObject.Dispose()
End Sub
And I hope you can understand the above code fragment very easily. I just changed the "Started" property to "StartMode".
Next: Managing "Indexing service" with WMI and VB. NET >>
More Visual Basic.NET Articles
More By Jagadish Chaterjee