NCSA SCADA
asked on
VB.Net - trying to kill a remote process with wmi
I am trining to kill a remote process using WMI and I get an invalid query error. I'm not sure what I'm doing wrong... any help would be great... thanks
Dim Computername As String = ComboBox1.SelectedValue
Dim colProcesses As ManagementObjectSearcher
Dim colObserver As New ManagementOperationObserver
Dim refProcess As ManagementObject
Dim sProcess As String = "spoolsv"
Dim options As ConnectionOptions
options = New ConnectionOptions()
options.Username = "User"
options.Password = "Passwords"
colProcesses = New ManagementObjectSearcher("Select * FROM Win32_Process WHERE Name = spoolsv.exe")
colProcesses.Scope = New ManagementScope("\\" & Computername & "\root\cimv2", options)
Try
colProcesses.Scope.Connect()
If colProcesses.Get.Count = 0 Then
Else
Try
For Each refProcess In colProcesses.Get
refProcess.InvokeMethod(colObserver, "Terminate", Nothing)
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
ASKER
That looks to have cleaned up the query (I feel silly for that one) but now I get the following
rpc server is unavailable - exception from hrsult:0x800706ba
I am able to query the status of the proceses and services but not stop
rpc server is unavailable - exception from hrsult:0x800706ba
I am able to query the status of the proceses and services but not stop
so the script just looks like? Where does it fail?
Firewall on the remote Client off? Does it work Local?
Firewall on the remote Client off? Does it work Local?
ASKER
there is no firewall on the remote system...
I receive the an error message from this catch
I receive the an error message from this catch
Try
For Each refProcess In colProcesses.Get
refProcess.InvokeMethod(colObserver, "Terminate", Nothing)
Next
Catch ex As Exception
MsgBox("1" & ex.Message)
End Try
Comment out the InvokeMethod line to see if that is the source of the error or the retrieval of processes.
ASKER
Yep.... it is the source
ASKER
did you send the link becuase of the domain reference... the remote server is not part of a domain.... the account I am using is an admin, and it looks like I am making it past the connection .. the query looks to be working as if cloprocesses.get.count was 0 it would never make to the invokemethod...
If there is somthing else you wanted me to look at please let me know with more detail...
Thanks for the info
any ideas experts
If there is somthing else you wanted me to look at please let me know with more detail...
Thanks for the info
any ideas experts
>.. the account I am using is an admin
Admin of the PC running this program or admin of the pc where you are killing the process?
Admin of the PC running this program or admin of the pc where you are killing the process?
ASKER
It is an admin on the remote system
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
colProcesses = New ManagementObjectSearcher("