Sign in to follow this  
Followers 0
neo291

Detecting SUDDEN/ABNORMAL comp shutdown/restart

8 posts in this topic

Can ne1 pls guide me on how to detect abnormal/sudden shutdown/restart of comp which may be coz of electricity outages or ne other problem with the comp ?

So far i have been only able to find @EXITMETHOD, but this dont deal with sudden shutdowns/restarts.


I'm not a programmer. Just a Power User.

Share this post


Link to post
Share on other sites



If your computer suddenly turns off there is nothing that can be done. If there is a shutdown command issued by the user then there should be a broadcast message to all top level windows.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

True. But then there r certain applications which can detect sudden closeur wich cud be coz of sudden restart/shutdown, example, yahoo messenger's plugins. It starts them in safe mode on next boot.

Bigger example will be windows runing a disk(edit) scan after each sudden restart.

So i was just thinkin of addin this sorta functionality to my script.

So far i have figured out only one workaround...its pretty lame though, but m sure some1 here can come up with better way to get it done.

The workaround is to create a file to flag the type of shutdown occured. If script is closed either coz of normal shutdown or closed by user then it'll put a "1" in that file, otherwise if its not a proper closeur of script then there wont be ne "1" in that file, wich need to be checked each time script starts that wats the flag level in that file.

But then m not totally convinced with it so lookin forward to more robust way to get this workaround done.

Thanx! n Rgrds

Edited by neo291

I'm not a programmer. Just a Power User.

Share this post


Link to post
Share on other sites

Writing a "1" in a file should work, as long as you remember to reset it upon start to "0" or something like that. Thats the same methodology I would expect Windows Media Player uses when it turns off all plug-ins after a "sudden shutdown".

Share this post


Link to post
Share on other sites

anyways I was ablr to get what I wanted out of this conversation guys, I meant @EXITMETHOD


[font="Book Antiqua"]Thanks`A[/font]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I think Windows just sets a flag to something like "Normal Shutdown = 0" after a successful boot, and when you shut down, one of the last things done is to set it to "Normal Shutdown = 1", the flag is checked upon each boot and if it wasn;t set, it goes into the bootmenu/checkdisk crap. I don't think a shotdown as you're describing gives the OS any opportunity for housekeeping.

I'd be looking at hardware....

Thermal problems like a dead cpu fan, or dead video card fan, dirty cpu heatsink, plugged up case vents, poor case ventilation. Or, checking the mobo for swollen capacitors or ones that have barfed out their electolyte. Or, a weak power supply.

Or, possibly a corrupted device driver or corrupted OS files. Maybe update/reinstall your critical drivers, or do a repair install of Windows.

Edit: Oops, just noted the date of the OP's post. this be a year-old thread resurrected. Ahem...

Edited by Spiff59

Share this post


Link to post
Share on other sites

The method was mentioned above, but I wanted to give you some code.. Just for kicks. If you close this script from the Task Manager or by sudden computer stop by power outage, then it will prompt with a safe mode message.

Look at Func OnAutoItExit() in the helpfile for some more information.

;; Stuff that deals with correct shutdown
$sFile = @TempDir & "\lolhacks123456.tmp"
$bSafeMode = False
If ( FileExists($sFile) ) Then
    $bSafeMode = True
    FileDelete($sFile)
EndIf

FileWrite($sFile,"lawl")
;; Main application

If ( $bSafeMode == True ) Then
    MsgBox(0,"Your App", "This application did not shut down correctly the last time it was started. It will now run in safe mode and is never going to give you up or run around and desert you!")
EndIf

While 1
    Sleep(1000)
WEnd

;; End main

;; Functions
Func OnAutoItExit()
    FileDelete($sFile)
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0