neo291 Posted July 1, 2008 Share Posted July 1, 2008 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. Link to comment Share on other sites More sharing options...
weaponx Posted July 1, 2008 Share Posted July 1, 2008 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. Link to comment Share on other sites More sharing options...
neo291 Posted July 1, 2008 Author Share Posted July 1, 2008 (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 July 1, 2008 by neo291 I'm not a programmer. Just a Power User. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 1, 2008 Share Posted July 1, 2008 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". .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
anandchakru Posted February 8, 2009 Share Posted February 8, 2009 anyways I was ablr to get what I wanted out of this conversation guys, I meant @EXITMETHOD [font="Book Antiqua"]Thanks`A[/font] Link to comment Share on other sites More sharing options...
Spiff59 Posted February 8, 2009 Share Posted February 8, 2009 (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 February 8, 2009 by Spiff59 Link to comment Share on other sites More sharing options...
jvanegmond Posted February 8, 2009 Share Posted February 8, 2009 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 github.com/jvanegmond Link to comment Share on other sites More sharing options...
BrettF Posted February 8, 2009 Share Posted February 8, 2009 Firefox is a great example of using restoration of sessions after crash etc. Nice example Manadar Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now