Solved

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

Posted on 2003-11-24
8
340 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
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now