473,626 Members | 3,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Use ShellExecute = false;
p.StartInfo.Fil eName = ExePath;
p.StartInfo.Arg uments = "";
p.Start();
p.PriorityClass = ProcessPriority Class.BelowNorm al;
}
catch (Exception exc) //Win32Exception err
{
Console.Writeli ne(exc.Message) ;
}
p.WaitForExit() ;
if (p.ExitCode == 0)
{
tbLog.Text += "All ok." + Environment.New Line;
}
else
{
tbLog.Text += "Exit code: " + p.ExitCode.ToSt ring() +
Environment.New Line;
}


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 4165
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********@vir gilio.itwrote in message
news:11******** *************@j 44g2000cwa.goog legroups.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.Use ShellExecute = false;
p.StartInfo.Fil eName = ExePath;
p.StartInfo.Arg uments = "";
p.Start();
p.PriorityClass = ProcessPriority Class.BelowNorm al;
}
catch (Exception exc) //Win32Exception err
{
Console.Writeli ne(exc.Message) ;
}
p.WaitForExit() ;
if (p.ExitCode == 0)
{
tbLog.Text += "All ok." + Environment.New Line;
}
else
{
tbLog.Text += "Exit code: " + p.ExitCode.ToSt ring() +
Environment.New Line;
}


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********@vir gilio.itwrote in message
news:11******** *************@j 44g2000cwa.goog legroups.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.Use ShellExecute = false;
p.StartInfo.Fil eName = ExePath;
p.StartInfo.Arg uments = "";
p.Start();
p.PriorityClass = ProcessPriority Class.BelowNorm al;
}
catch (Exception exc) //Win32Exception err
{
Console.Writeli ne(exc.Message) ;
}
p.WaitForExit() ;
if (p.ExitCode == 0)
{
tbLog.Text += "All ok." + Environment.New Line;
}
else
{
tbLog.Text += "Exit code: " + p.ExitCode.ToSt ring() +
Environment.New Line;
}


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********@vir gilio.itwrote in message
news:11******** **************@ 45g2000cws.goog legroups.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********@vir gilio.itwrote in message
news:11******* **************@ j44g2000cwa.goo glegroups.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.Use ShellExecute = false;
p.StartInfo.Fil eName = ExePath;
p.StartInfo.Arg uments = "";
p.Start();
p.PriorityClass = ProcessPriority Class.BelowNorm al;
}
catch (Exception exc) //Win32Exception err
{
Console.Writeli ne(exc.Message) ;
}
p.WaitForExit() ;
if (p.ExitCode == 0)
{
tbLog.Text += "All ok." + Environment.New Line;
}
else
{
tbLog.Text += "Exit code: " + p.ExitCode.ToSt ring() +
Environment.New Line;
}


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
4177
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 continue the execution code on a other button or anything else. Example 1) Click anywhere intercept click->Execute the code in function click().
14
5258
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 step through the VBA code, the crash does not occur. What is different about stepping through code instead of just running it? Any idea how to find the cause? I know about where it happens, but since it is Access itself crashing, finding a...
9
4492
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 with the same symptoms). 1) Working database, Compile/Save All works, Create MDE works 2) Touch the references (mark a new reference, OK, then Unmark) 3) Create MDE works 4) Compile/Save All works 5) Now try creating MDE from the compiled...
0
943
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
5644
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 displayed. It goes away when the mouse is pointed over the icon. I wonder if there is any way to force system tray refresh during the VB.NET app crash? I tried to add some code in the finalize but it didn't do anything. I think
5
6022
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 restarted... The tablespace and table states are normal and count is very small ..(i.e. 150 recs) ..also there are no long or lob columns in that table..
12
5569
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 write information into a log file. The problem is, i'm not confident that information i write to the log gets saved onto the hard drive before the crash occurs. My understanding of hard drives and OS are that because hard drives are so slow,...
110
10546
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 case scenario for MyISAM backend? Also is it possible to not to lose data but get them corrupted?
0
8268
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8202
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8641
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8366
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8510
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5575
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1512
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.