Is there a way to determine when the last time a specific machine last ran a process?
I can use the following to determine if a process is running, but the application cannot grab the process if it has since stopped.
Process[] process = Process.GetProcessesByName(processName, serverName);
WMI provides a way to track processes starting and terminating with the Win32_ProcessTrace classes. Best shown with an example. Start a new Console application, Project + Add Reference, select System.Management. Paste this code:
Edit the manifest so this program runs elevated. Then simply start some programs to see it at work. Beware that it is not especially quick.
You won't be able to do this using the
Process
class. However, it should be possible to figure out when an application was last run by configuring audit process tracking in Windows. The following links might get you started:The process tracking will create entries in the Windows event log which you can then access using C#.