Solved

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

Posted on 2003-11-24
8
342 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

863 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

23 Experts available now in Live!

Get 1:1 Help Now