RE: How to ensure a script to run when system crashes



When you say 'Crash' do you mean 'Forced Shutdown'? or System Crash (as in
Blue Screen or Complete Freeze)?
If the latter (Crash) there is no way to run some code AFTER the system has
crashed... and if you could predict your computer was about the 'Crash'
microsoft would have put some friendly message like:
'Just thought we should let you know... Your computer is ABOUT TO CRASH, so
save all your work really quick'
Maybe I'm wrong, but I dont think it works like this :P

I can think of two reasons (currently) why you might want to do this:
You perhaps want to stop all the active connections/broadcasts that occur on
a network even after a computer is turned off?
Your best bet is disabling Wake-On-Lan in the BIOS which should disable your
network adapter once the computer shuts down. If this doesn't work theres
bound to be a BIOS setting to turn LAN off after powerdown. (that or tell
your customers to unplug their computers at the end of the day (good
power-spike prevention :P lol))

Another reason you might want this is that you dont want a wireless card
authenticating (using a certificate) until a user is logged in (and the cert
becomes available). You might be able to stop this by running your disable
script on system load (before anyone logs in). You could do this several ways:
As a Service:
This would allow you to automatically detect stop/start of the computer (not
'Crash' though) as well as any power (eg. Suspend/Hibernate) events. Use
VB.NET/C#.NET 2005 - works a treat (.NET 2.0 has excellent WMI support as
well!).
In Group Policy:
In the Local Computer Policy (Run: gpedit.msc) --> Computer Configuration
--> Windows Settings --> Scripts (Startup/Shutdown)
You can add scripts which run at startup/shutdown (eg. Before a user Logs in)
You can then add other scripts for user Login/Logout:
In the Local Computer Policy --> User Configuration --> Windows Settings -->
Scripts (Logon/Logoff)

All these settings could (should) be placed over an Organisational Unit in
your Domain, allowing you to run these scripts over a group (or all) of your
workstations/users.

Hope this helps, if i've got it all wrong I apologyse.

Regards,

G. Sharp


"Lopamudra" wrote:

Hi,

I am running wmi script to enable one of the LAN connections during system
shutdown. This is done by calling a VB exe during system startup which is
idle all the time and when the system shuts down, it tries to unload the exe
causing a certain script to get invoked (in Onunload event). This works fine
for shut down but the unload event is not called when the system crashes. Is
there a sure shot way to ensure that the script runs when the system crashes
as well.

Regards
Lopamudra Patnaik
.



Relevant Pages

  • Re: on input form showing error message for duplicate entry.
    ... my SITE will not crash. ... you can 'what if' the daylights out of this script. ... this scenario DOES NOT exist in this script. ... | i think, there is no sense to speak more about it, think again about my ...
    (alt.php)
  • Re: on input form showing error message for duplicate entry.
    ... this age you should to handle all, everytime some1 whants to crash you site ... i think, there is no sense to speak more about it, think again about my ... it means we can write to parts of script ...
    (alt.php)
  • Re: segmentation fault at the end of script
    ... >This script is launch by a script shell on an linux machine like this: ... Have you tried examining the core dump with gdb to give ... using a program that'll deliberately crash: ...
    (comp.lang.php)
  • RE: Kernel Panic
    ... I think I see what caused the kernel to crash. ... >and slapped a 1GB SCSI disk on it (the system isn't intended ... >>I just wrote a little shell script that, ...
    (FreeBSD-Security)
  • Re: 2.6.17-mm4
    ... the crash is independent on lockdep enabled or disabled. ... for the config and the crash.log. ... Disabling it makes the -mm4 allyesconfig ... which crashes the box afterwards. ...
    (Linux-Kernel)