Nathan McKaskle Nathan McKaskle - 3 years ago 117
C# Question

Process.Kill() Method is Missing

So I've looked around all over the place and nobody seems to have this problem. I added using System.Diagnostics to the list of references, so Process exists, but not the Kill method. Nowhere does it show up in the Intellisense menu. It has a Start method. No Kill method. It has a GetProcessesByName method but no Kill method. What is going on here?

foreach(var x in objServerList)
{
Process[] proc = Process.GetProcessesByName("myproc.exe", x);
proc.ki //nope it's missing, not in the long list of options
Process.ki //nope, not there either
}

Answer Source

proc is an array of Process so it'll have methods relevant to arrays. Access a specific index and then you will have the methods of the Process type:

proc[index].Kill()

By the way your second attempt of Process.Kill does not work because the class Process does not have a static method of Kill

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download