that doesnt seem to work remotely
here is the code i am trying to use now, i get a cast error now
Function WMIKill(ByVal Server As String, ByVal sProcess As String)
Dim strMoniker, strQuery As String
Dim colProcesses As Management.ManagementObjectSearcher
Dim refProcess As Management.ManagementObject
colProcesses = New Management.ManagementObjectSearcher("SELECT * FROM
Win32_Process WHERE Handle = '" & sProcess & "'")
colProcesses.Scope = New Management.ManagementScope("\\" & Server &
"\root\cimv2")
If colProcesses.Get.Count = 0 Then
ListOutPut.Items.Add(sProcess & " - Not found on " & Server)
Else
'there are some matching process, so loop through and kill
For Each refProcess In colProcesses.Get
If refProcess.InvokeMethod("Terminate", refProcess("handle")) = 0 Then
ListOutPut.Items.Add("(PID " & refProcess("Handle") & ") " & _
refProcess("Name") & _
" Terminated on - " & Server)
Else
ListOutPut.Items.Add("Unable to terminate - " & _
refProcess("Name") & " on " & Server)
End If
Next
End If
End Function
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:Ok**************@TK2MSFTNGP11.phx.gbl...
Hi,
You can do it without the wmi. Take a look at the process class.
' To list processes
Dim p As Process
For Each p In Process.GetProcesses
Debug.WriteLine(p.ProcessName)
Next
' to kill a process
'p.Kill()
Ken
----------------
"Keith Grefski" <ma********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...I cant seem to figure out how to terminate a process in vb.net i can do
it using vbscript and wmi but terminate doesnt seem to exist in the
available classes for wmi under vb.net