Click here to Skip to main content
15,885,025 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to programatically monitor and log the activity of processes running in a computer. How can we get a list of processes running in windows each time a process starts and ends? Is there an event in .NET that is triggered when a process starts or ends?
Any help will be very appreciated.

What I have tried:

I didn't find a proper class to complete managing of processes.
Posted
Updated 19-Oct-16 6:06am
Comments
[no name] 18-Oct-16 13:37pm    
No "event" that I know of. Most of the solutions I have seen doing what you want to do poll the running processes.
Michael_Davies 18-Oct-16 14:24pm    
WMI allows you to capture events and includes process creation.

For a start see http://stackoverflow.com/questions/10139270/process-start-event-using-wmi-not-all-process-starts-being-detected

1 solution

You'll need to use WMI, and subscribe to the Win32_ProcessStartTrace[^] and Win32_ProcessStopTrace[^] events, or the lower-level __InstanceCreationEvent[^] and __InstanceDeletionEvent[^] events.

There's an example in this StackOverflow answer[^] which monitors processes with a specific name.
 
Share this answer
 
Comments
grivix 22-Oct-16 11:46am    
Thank you Michael Davies, thank you Richard Deeming. I'll try it using WMI as you suggest.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900