-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
  • 11,360
  • 21
  • 88
  • 132
TN888
  • 7,463
  • 9
  • 45
  • 83
  • **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
  • 94,086
  • 102
  • 195
  • 339