Watching other processes
Over a year ago, I wrote a Windows Service in .NET to watch the web server process of IIS (InetInfo.exe) and to stop that service and restart it under certain conditions. I had set the app up to run under a timer and wake up every couple of minutes to check the state of IIS. While it worked, I always wondered about how do I check for processes that are currently running and a few other things.
Now, thanks to Roy Osherove, I have almost all of what I want. He gave me the little kick in the "code" pants to head me into a better direction. I took his code and modified it to what is at the end of this post. My next step is going to be how to find out when a new process starts...............
static void Main(string args)
Process  localByName = Process.GetProcessesByName("notepad");
localByName[i].Exited += new EventHandler(OnExit);
localByName[i].EnableRaisingEvents = true;
private static void OnExit(object sender,EventArgs e)
Console.WriteLine("The process was finished!");