Connecting Tech Pros Worldwide Forums | Help | Site Map

Intercept crash of an external exe

lookaround
Guest
 
Posts: n/a
#1: Nov 23 '06
Hi everyone,
I need some help...
I call an external exe (a command-line tool) with Process.Start through
this code:

try
{
p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = ExePath;
p.StartInfo.Arguments = "";
p.Start();
p.PriorityClass = ProcessPriorityClass.BelowNormal;
}
catch (Exception exc) //Win32Exception err
{
Console.Writeline(exc.Message);
}


p.WaitForExit();
if (p.ExitCode == 0)
{
tbLog.Text += "All ok." + Environment.NewLine;
}
else
{
tbLog.Text += "Exit code: " + p.ExitCode.ToString() +
Environment.NewLine;
}




If the external exe crashes, it displays a window:
"An error occurred ... application will be closed"
"For further information ... click here" (I translate from Italian).
and the two buttons "Debug" and "Close"

Until I click on Debug or Close the calling application freezes.
After I click on one of the two buttons, the calling app return
responsive and logs the err message (exit code).

The fact that application freezes while executing external exe is not a
problem; the problem is that the app has to be run in un-attended
mode...
So it should intercept the external crash, handle the crash and go on,
not wait for a click by the user.

I should also check if the external exe runs for more than a fixed
number of seconds: if it runs longer, I should have to kill the exe and
handle the unfinished execution (without no external input or click)

Any help?

Thank you very much in advance for any idea!


Chris
Guest
 
Posts: n/a
#2: Nov 24 '06

re: Intercept crash of an external exe


If I understand you correctly:
1) You are launching an exe using Process.Start()
2) When the exe you launched crashes, windows puts up a dialog asking if you
want to debug it
3) Until something clicks the dialog, the exe doesn't return, and your
origanal app is waiting
4) You want to know how to clear that dialog automatically

If all that is correct, then this might help:
1) You could spawn a seperate thread and enumerate windows - then send a
click event to the correct button whenever you see the dialog you want
cleared
2) Or, you could just tell windows not to put that dialog up anymore. Check
out
http://www.microsoft.com/technet/pro....mspx?mfr=true

I think that will work for you.

-Chris



"lookaround" <lookaround@virgilio.itwrote in message
news:1164298604.471666.74880@j44g2000cwa.googlegro ups.com...
Quote:
Hi everyone,
I need some help...
I call an external exe (a command-line tool) with Process.Start through
this code:
>
try
{
p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = ExePath;
p.StartInfo.Arguments = "";
p.Start();
p.PriorityClass = ProcessPriorityClass.BelowNormal;
}
catch (Exception exc) //Win32Exception err
{
Console.Writeline(exc.Message);
}
>
>
p.WaitForExit();
if (p.ExitCode == 0)
{
tbLog.Text += "All ok." + Environment.NewLine;
}
else
{
tbLog.Text += "Exit code: " + p.ExitCode.ToString() +
Environment.NewLine;
}
>
>
>
>
If the external exe crashes, it displays a window:
"An error occurred ... application will be closed"
"For further information ... click here" (I translate from Italian).
and the two buttons "Debug" and "Close"
>
Until I click on Debug or Close the calling application freezes.
After I click on one of the two buttons, the calling app return
responsive and logs the err message (exit code).
>
The fact that application freezes while executing external exe is not a
problem; the problem is that the app has to be run in un-attended
mode...
So it should intercept the external crash, handle the crash and go on,
not wait for a click by the user.
>
I should also check if the external exe runs for more than a fixed
number of seconds: if it runs longer, I should have to kill the exe and
handle the unfinished execution (without no external input or click)
>
Any help?
>
Thank you very much in advance for any idea!
>
lookaround
Guest
 
Posts: n/a
#3: Nov 24 '06

re: Intercept crash of an external exe


Thank you for tips!
Quote:
If I understand you correctly:
1) You are launching an exe using Process.Start()
2) When the exe you launched crashes, windows puts up a dialog asking if you
want to debug it
3) Until something clicks the dialog, the exe doesn't return, and your
origanal app is waiting
4) You want to know how to clear that dialog automatically
You understood perfectly.

Quote:
If all that is correct, then this might help:
1) You could spawn a seperate thread and enumerate windows - then send a
click event to the correct button whenever you see the dialog you want
cleared
I'm executing the exe from an asp.net application page.
I'm not so experienced with Thread and capture external windows events
and clicks...
Should you suggest me some tutorial or web page where I can found some
code to start from?
Thanks again in advance..
Quote:
2) Or, you could just tell windows not to put that dialog up anymore. Check
out
http://www.microsoft.com/technet/pro....mspx?mfr=true
>
I think that will work for you.
>
-Chris
>
>
>
"lookaround" <lookaround@virgilio.itwrote in message
news:1164298604.471666.74880@j44g2000cwa.googlegro ups.com...
Quote:
Hi everyone,
I need some help...
I call an external exe (a command-line tool) with Process.Start through
this code:

try
{
p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = ExePath;
p.StartInfo.Arguments = "";
p.Start();
p.PriorityClass = ProcessPriorityClass.BelowNormal;
}
catch (Exception exc) //Win32Exception err
{
Console.Writeline(exc.Message);
}


p.WaitForExit();
if (p.ExitCode == 0)
{
tbLog.Text += "All ok." + Environment.NewLine;
}
else
{
tbLog.Text += "Exit code: " + p.ExitCode.ToString() +
Environment.NewLine;
}




If the external exe crashes, it displays a window:
"An error occurred ... application will be closed"
"For further information ... click here" (I translate from Italian).
and the two buttons "Debug" and "Close"

Until I click on Debug or Close the calling application freezes.
After I click on one of the two buttons, the calling app return
responsive and logs the err message (exit code).

The fact that application freezes while executing external exe is not a
problem; the problem is that the app has to be run in un-attended
mode...
So it should intercept the external crash, handle the crash and go on,
not wait for a click by the user.

I should also check if the external exe runs for more than a fixed
number of seconds: if it runs longer, I should have to kill the exe and
handle the unfinished execution (without no external input or click)

Any help?

Thank you very much in advance for any idea!
Chris
Guest
 
Posts: n/a
#4: Nov 25 '06

re: Intercept crash of an external exe


I wasn't actually recommending option 1 as a viable choice :}

I recommend you make option 2 work for you if you can; if for some reason
you can't, reply back to me (not the whole group) and I'll help you get your
problem solved.

-Chris



"lookaround" <lookaround@virgilio.itwrote in message
news:1164353107.190924.187120@45g2000cws.googlegro ups.com...
Quote:
Thank you for tips!
>
Quote:
>If I understand you correctly:
>1) You are launching an exe using Process.Start()
>2) When the exe you launched crashes, windows puts up a dialog asking if
>you
>want to debug it
>3) Until something clicks the dialog, the exe doesn't return, and your
>origanal app is waiting
>4) You want to know how to clear that dialog automatically
>
You understood perfectly.
>
>
Quote:
>If all that is correct, then this might help:
>1) You could spawn a seperate thread and enumerate windows - then send a
>click event to the correct button whenever you see the dialog you want
>cleared
>
I'm executing the exe from an asp.net application page.
I'm not so experienced with Thread and capture external windows events
and clicks...
Should you suggest me some tutorial or web page where I can found some
code to start from?
Thanks again in advance..
>
Quote:
>2) Or, you could just tell windows not to put that dialog up anymore.
>Check
>out
>http://www.microsoft.com/technet/pro....mspx?mfr=true
>>
>I think that will work for you.
>>
>-Chris
>>
>>
>>
>"lookaround" <lookaround@virgilio.itwrote in message
>news:1164298604.471666.74880@j44g2000cwa.googlegr oups.com...
Quote:
Hi everyone,
I need some help...
I call an external exe (a command-line tool) with Process.Start through
this code:
>
try
{
p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = ExePath;
p.StartInfo.Arguments = "";
p.Start();
p.PriorityClass = ProcessPriorityClass.BelowNormal;
}
catch (Exception exc) //Win32Exception err
{
Console.Writeline(exc.Message);
}
>
>
p.WaitForExit();
if (p.ExitCode == 0)
{
tbLog.Text += "All ok." + Environment.NewLine;
}
else
{
tbLog.Text += "Exit code: " + p.ExitCode.ToString() +
Environment.NewLine;
}
>
>
>
>
If the external exe crashes, it displays a window:
"An error occurred ... application will be closed"
"For further information ... click here" (I translate from Italian).
and the two buttons "Debug" and "Close"
>
Until I click on Debug or Close the calling application freezes.
After I click on one of the two buttons, the calling app return
responsive and logs the err message (exit code).
>
The fact that application freezes while executing external exe is not a
problem; the problem is that the app has to be run in un-attended
mode...
So it should intercept the external crash, handle the crash and go on,
not wait for a click by the user.
>
I should also check if the external exe runs for more than a fixed
number of seconds: if it runs longer, I should have to kill the exe and
handle the unfinished execution (without no external input or click)
>
Any help?
>
Thank you very much in advance for any idea!
>
>
Closed Thread