Detect end of running process without Admin rights
I was wondering if it was possible to detect when a certain process gets killed or closed the normal way. With other words if the process is removed from the process list.
I know it's possible by using WMI and the System.Management.ManagentEventWatcher, however this needs Administrator rights, I'd prefer if it开发者_开发知识库's done without requiring those.
Since at the moment I use Process.Start("ProgramX.exe"); I'd like to find out when that program is closed or terminated. So that I can act upon that.
If you start the process yourself then you can wait for it to finish using Process.WaitForExit method. Note that waiting is a blocking operations and it's best if you do in in another thread, then signal the event from that thread.
Ex:
var process = Process.Start("ProgramX.exe");
...
process.WaitForExit();
精彩评论