<p>From C# on a Windows box, is there a way to find out how a process was stopped? 
I've had a look at the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx" rel="nofollow noreferrer">Process</a> class, managed to get a nice friendly callback from the Exited event once I set <code>EnableRaisingEvents = true;</code> but I have not managed to find out whether the process was killed or whether it exited naturally?</p>

[{'answer_id': 58056, 'author': 'Antoine Aubry', 'author_id': 2680, 'author_profile': 'https://Stackoverflow.com/users/2680', 'pm_score': 0, 'selected': False, 'text': '<p>You can use the return code of the process for that. If your process returns a non-zero value from its Main method, you can then check whether or not the process exited by itself (the return value matches).</p>\n'}, {'answer_id': 58110, 'author': 'Guy Starbuck', 'author_id': 2194, 'author_profile': 'https://Stackoverflow.com/users/2194', 'pm_score': 3, 'selected': True, 'text': '<p>Fire up Process Monitor (from Sysinternals, part of Microsoft), run your process and let it die, then filter the Process Monitor results by your process name -- you will be able to see everything that it did, including exit codes.</p>\n'}]
['https://Stackoverflow.com/questions/58036', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6023/']