-7

How can I detect starting of a new process? I wanna kill some other than my processes, when they are starting. Is there any way to that?

tshepang
  • 12,111
  • 21
  • 91
  • 136
TN888
  • 7,659
  • 9
  • 48
  • 84
  • **Please give a comment why are you downvoting my question. Thank you** – TN888 Aug 24 '13 at 19:33
  • possible duplicate of [How to detect a process start & end using c# in windows?](http://stackoverflow.com/questions/8455873/how-to-detect-a-process-start-end-using-c-sharp-in-windows) – DaveShaw Aug 24 '13 at 19:35

1 Answers1

1

Well, your question is not clear but you should have a look Process.GetProcessesByName method.

Creates an array of new Process components and associates them with all the process resources on the local computer that share the specified process name.

For example;

Process[] Runningcmd = Process.GetProcessesByName("cmd");
if (Runningcmd.Length == 0)
  Console.WriteLine("Command Line is not running");
else
    foreach(var p in Runningcmd )
    {
       p.Kill();
    }
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364