Is there any way to determine if process was invoked by current application? I’m opening and Excel Interop process, handling files, etc, and after that I want to close only this Excel process which I’ve invoked.
Something like this:
Process[] pProcess = System.Diagnostics.Process.GetProcessesByName("Excel");
foreach (var process in pProcess)
{
if (process.Parent == "MyApp.exe") process.Kill();
}
Usage:
Code:
Source: https://stackoverflow.com/a/2336322/706867