I am trying to get the exit code of an application (IE) after the process
closes. On my system I keep getting an exception error. "No process is
associated with the object." The Process class is suppose to keep some
administrative information available on a closed process (i.e., the ExitCode,
HasExited, etc.) but it seems to not do this. Does anyone know how to get
around this problem?
The code is a simple C# form with a button. The button's click code is below.
private void button1_Click(object sender, EventArgs e)
{
Process spawned = Process.Start("iexplore.exe");
Thread.Sleep(2000);
if (spawned.Responding)
{
Thread.Sleep(10000);
spawned.CloseMainWindow();
spawned.Close();
spawned.Refresh();
int exitCode = spawned.ExitCode;
}
}
--
-----------
Thanks,
Steve