Solved

vb.NET: Detect whether program is closed because of reboot or just program crash.

Posted on 2003-11-24
8
349 Views
Last Modified: 2010-05-18
I'm creating a vb.NET program that monitors two processes that are running in task manager. java.exe and inetinfo.exe.  Basically, my program tells me if either of those processes are shut down (crash) and pages me.

My question is this: Is there a way to tell if the program that I'm monitoring (java.exe or inetinfo.exe) are shut down because someone is rebooting the box vs. the programs being stopped by an administrator or crashing.

Each time these programs stop I get notification via pager and I DON'T want to get paged if the server is being rebooted for maintenance or whatever.

Thanks 1,000,000
gtosi
0
Comment
Question by:gtosi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 42

Expert Comment

by:frodoman
ID: 9812142
I'd suggest a timer or counter of some sort.  

When your app finds the monitored program is not running, it could increment a counter or start a timer.  Then tie to code to page you into the time elapsed / count, etc. - basically provide enough of a delay for a reboot to occur and the program to begin running again.

Of course for this to work you'll need to make sure whenever your app finds the monitored program is running, it'll need to zero out the counter / timer.
0
 

Author Comment

by:gtosi
ID: 9812280
I guess, in short what I need is something like this:

For lack of a better term I need the "onServerBeingShutdown(Rebooted)" event.

I want paged when my process inetinfo.exe drops out of taskmgr but not when it's because server is rebooted.
0
 
LVL 42

Expert Comment

by:frodoman
ID: 9812316
I was hoping to offer an alternate possibility (which may or may not work for you).

I'm not aware of any event such as what you're looking for.  I would be surprised if it existed because if it exists then I would think it would be possible for malicious code to intercept the event - that could lead to a virus that won't let you turn off your computer (at least short of yanking the plug out of the wall...).
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:Z_Beeblebrox
ID: 9813896
Hi,

Is your program running on the same server as the two processes being monitored? If so, you could just delay sending the page long enough that the OS gets around to shutting down your program as well if a shutdown is happening. So say after the program notices that one of the processes is stopped, it could set a flag. If, after say 15 seconds, the program is still running, then send out the page. You might need to tweak the delay a little, and its not the most elegant of solutions, but it should work.

Zaphod.
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 250 total points
ID: 10590219
Moderator, my recommended disposition is:

    Accept Z_Beeblebrox's comment(s) as an answer.
   **** note: Another option is handle WM_ENDSESSION

Dan Rollins -- EE database cleanup volunteer
0
 
LVL 7

Expert Comment

by:Z_Beeblebrox
ID: 10590250
I think the comment made by DanRollins (WM_ENDSESSION) is actually the best solution to this problem, I just wasn't aware of it when I first commented on this question. But the WM_ENDSESSION windows message is in effect an "onServerBeingShutdown(Rebooted)" event!

Zaphod.
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month5 days, 19 hours left to enroll

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question