473,390 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

Intercept crash of an external exe

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!

Nov 23 '06 #1
3 4147
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" <lo********@virgilio.itwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
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!
Nov 24 '06 #2
Thank you for tips!
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.

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..
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" <lo********@virgilio.itwrote in message
news:11*********************@j44g2000cwa.googlegro ups.com...
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!
Nov 24 '06 #3
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" <lo********@virgilio.itwrote in message
news:11**********************@45g2000cws.googlegro ups.com...
Thank you for tips!
>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.

>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..
>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" <lo********@virgilio.itwrote in message
news:11*********************@j44g2000cwa.googlegr oups.com...
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!
Nov 25 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: zoltix | last post by:
Hi, I am beginner in JavaScript. I would like to intercept all click events on my document. I use this function for that document.onmousedown=click;. It works well. But I would like to...
14
by: JK Peck | last post by:
I have a fairly large Access application that ran correctly in Access 2000. After upgrading to Access 2003 (and recompiling and updating references), it reliably crashes at a certain point. If I...
9
by: fishbaugher | last post by:
I have encountered some interesting crashes lately (Access97). Here is the symptom (after several days of different kinds of rebuilds including import and LoadFromText, all resulting in databases...
0
by: juky | last post by:
Hi all, I need to implement (vb .net) a function that will be able to intercept error coming from another external application. Is there a way to do ? Any starting point? Thank you. Juky
4
by: Tom | last post by:
Hello, System tray icon informs users that the apps is running in the background. However, there are instances that the app might crash and after that the app icon in the system tray is still...
5
by: Purple-D | last post by:
we have a weird issue.. When we try to do select count(*) from a table..say tab_a.. we get back the count. but the moment we try to do "select * from tab_a" ...the instance crashes and has to be...
12
by: benjamin.krulewitch | last post by:
I'm debugging an issue with a C program that causes the computer to crash, and I'm attempting to log information immediately before the crash occurs. I us my BKprintLog function (see below) to...
110
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say million of 1KB rows). In other words what is the worst...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.