Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2003-11-24
8
Medium Priority
?
351 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 1000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

722 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