[/COLOR]
[COLOR=black]dim s as string[/COLOR]
[COLOR=black]dim pass as boolean[/COLOR]
[COLOR=black]dim arr as array = System.ServiceProcess.ServiceController.GetServices()[/COLOR]
[COLOR=black]Dim i as integer = 0[/COLOR]
[COLOR=black] [/COLOR]
[COLOR=black]do until i = arr.length[/COLOR]
[COLOR=black]s=arr.tostring[/COLOR]
[COLOR=black]if s = "Service Name" then[/COLOR]
[COLOR=black]pass = true[/COLOR]
[COLOR=black]exit do[/COLOR]
[COLOR=black]end if[/COLOR]
[COLOR=black]i = i +1[/COLOR]
[COLOR=black]loop[/COLOR]
[COLOR=black] [/COLOR]
[COLOR=black]if i = arr.length then[/COLOR]
[COLOR=black]pass = false[/COLOR]
[COLOR=black]end if[/COLOR]
[COLOR=black]
Dim sc As System.ServiceProcess.ServiceController
For Each sc In System.ServiceProcess.ServiceController.GetServices()
MsgBox(sc.ServiceName)
Next
Dim gogo As Boolean = False
Dim op As String
If Directory.Exists("\\" & compname & "\c$\windows\system32") Then
op = "xp"
Else
op = "2k"
End If
Dim myconn As New System.Management.ConnectionOptions
With myconn
.Impersonation = System.Management.ImpersonationLevel.Impersonate
If op = "xp" Then
.Authentication = AuthenticationLevel.Packet
Else
.Authentication = AuthenticationLevel.Connect
End If
End With
Dim scope As System.Management.ManagementScope = New System.Management.ManagementScope("\\" & compname & "\root\cimv2", myconn)
scope.Connect()
Dim moOS As ManagementObjectSearcher = New ManagementObjectSearcher(scope.Path.ToString, "SELECT displayName FROM Win32_Service")
Dim moDS As ManagementObject
Dim dss As String
For Each moDS In moOS.Get
dss = moDS("DisplayName").ToString
If dss = "Service Name" Then
gogo = True
Exit For
End If
Next
SELECT DisplayName FROM Win32_Service WHERE DisplayName = 'something'