2

I wanted to know if anyone knows of a way to catch new applications starting or stopping on a computer. for instance, a user logs in and opens word, outlook, or IE. I want to catch that instance opening. I have been working with Process.

I am building a service that runs in the background and writes to the event log.

       public string applicationID()
    {
        Process p = new Process();
        string application = p.ProcessName.ToString();
        return application;
    }

I know to do a foreach to get the process list. Some pointers or samples would be great.

1 Answers1

0

Once you have the process object, you can add a handler to the "Exited" event to detect when it stops. Note that the "EnableRaisingEvents" property must be set to "True" for this to work, which you can set after you get the Process object using GetProcesses().

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.exited.aspx

BradleyDotNET
  • 60,462
  • 10
  • 96
  • 117