Dim co As ConnectionOptions = New ConnectionOptions()
'CREDENTIALS
With co
.Username = "username"
.Password = "password"
End With
Dim strComputer As String = "computername"
Dim scope As New System.Management.ManagementScope
scope=New System.Management.ManagementScope("\\" & strComputer & "\root\cimv2", co)
'CONNECT TO THE BOX
scope.Connect()
Dim query As ObjectQuery = New ObjectQuery("Select * from Win32_Service Where Name ='SERVICENAME' ")
Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher(scope, query)
Dim observer As ManagementOperationObserver = New ManagementOperationObserver()
Dim queryCollection As ManagementObjectCollection=searcher.Get()Dim m As ManagementObject
Dim args As Object
'START THE SERVICE
For Each m In queryCollection
m.InvokeMethod("StartService", args)
Next
'CREDENTIALS
With co
.Username = "username"
.Password = "password"
End With
Dim strComputer As String = "computername"
Dim scope As New System.Management.ManagementScope
scope=New System.Management.ManagementScope("\\" & strComputer & "\root\cimv2", co)
'CONNECT TO THE BOX
scope.Connect()
Dim query As ObjectQuery = New ObjectQuery("Select * from Win32_Service Where Name ='SERVICENAME' ")
Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher(scope, query)
Dim observer As ManagementOperationObserver = New ManagementOperationObserver()
Dim queryCollection As ManagementObjectCollection=searcher.Get()Dim m As ManagementObject
Dim args As Object
'START THE SERVICE
For Each m In queryCollection
m.InvokeMethod("StartService", args)
Next
No comments:
Post a Comment