Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

trap system tray error message (e.g. "No Disk" exception)


  • Please log in to reply
9 replies to this topic

#1 orbs

orbs

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 483 posts

Posted 13 January 2013 - 09:46 AM

hello all,

I'm having a script running FileCopy function, where the target happend to be an unstable hard drive.

I can replace my hard drive (and I will soon), but this is not my concern.

when FileCopy fails, I can read the return code and work with it, and that's fine; but Windows tends to get in the way with a baloon tip saying: "AutoIt v3: Windows - No Disk". my concern is what happens when this script runs on some other computer in my enterprize and encounters the same issue. I want to trap the error before Windows starts alarming the end-user with spooky messages.

see attached file for screenshot of the error message.

I considered that the script will check drive status before filecopy, but this does not handle instability of hardware, just the media being ready / not ready.

any suggestinos are welcome (also, is there a way to display a screenshot in the thread text?)

thanks,
Or

Attached Thumbnails

  • autoit-disk-error.png








#2 guinness

guinness

    I've a handle on the fiction

  • Developers
  • 15,644 posts

Posted 13 January 2013 - 04:57 PM

Probably best to get a new hard drive in all honesty.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasswordValidPasteBinPosts Per DayPreExpandQueue()SciTE JumpSHELLHOOKShunting-YardSignature CreatorStack()StringAddLF()/StringStripLF()StringEOLToCRLF()WM_COPYDATAMore Examples...
Updated: 12/04/2014


#3 orbs

orbs

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 483 posts

Posted 13 January 2013 - 06:11 PM

hello guiness, I must have failed to explain my purpose: I don't care for my disk, I will replace it, but I don't want my script to issue these messages on other machines which may have the same or similar hardware failure. so I want to trap these system messages before they appear and make my users call me with panic. I suspect this example is not the only system message regarding hardware failure which may occur, so I want to trap them all and process them inside the script.

#4 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 9,529 posts

Posted 13 January 2013 - 06:24 PM

Why wouldn't you want to let the user's know that your script has a problem because their drives are failing? It's called good customer service.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to an XP machine, and I'm not going to.

 

How to ask questions the smart way!

 

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.
Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.
_FileGetProperty - Retrieve the properties of a file SciTE Toolbar - A toolbar demo for use with the SciTE editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator

 

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.


#5 orbs

orbs

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 483 posts

Posted 13 January 2013 - 06:41 PM

hi BrewMan, consider this: if you were a not-too-computer-oriented user, how would you respond to this message suddenly popping up your screen?

I'd be happy to replace this message with a standard MsgBox saying something like "a hardware failure has occurred please contact your system administrator."

also, as I mentioned, I suspect this is only one example of a wide range of system failures that I would be happy if my script could detect and handle internally.

#6 guinness

guinness

    I've a handle on the fiction

  • Developers
  • 15,644 posts

Posted 13 January 2013 - 07:24 PM

However you present the message to the end user, they will always be like "what is happening!?"

Edit: Post a small reproducer too.

Edited by guinness, 13 January 2013 - 07:24 PM.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasswordValidPasteBinPosts Per DayPreExpandQueue()SciTE JumpSHELLHOOKShunting-YardSignature CreatorStack()StringAddLF()/StringStripLF()StringEOLToCRLF()WM_COPYDATAMore Examples...
Updated: 12/04/2014


#7 trancexx

trancexx

    Queen F. Elizabeth MCXI

  • Active Members
  • PipPipPipPipPipPip
  • 5,969 posts

Posted 13 January 2013 - 09:30 PM

Good practice is that your application controls displaying error messages. System does it and will do it only if you fail to handle critical type of errors.
This is done by calling SetErrorMode function as one of the first things you do in the script if there is even a remote possibility critical error will occur. See this example:
Global Const $SEM_FAILCRITICALERRORS = 1 ; This is the line. You are telling: I'll handle possible displaying of critical errors myself SetErrorMode($SEM_FAILCRITICALERRORS) ConsoleWrite(FileOpen("A:") & @CRLF) ; This line would create system's critical-error-handler message box for my system if I haven't called SetErrorMode passing SEM_FAILCRITICALERRORS argument Func SetErrorMode($iMode)     Local $aCall = DllCall("kernel32.dll", "dword", "SetErrorMode", "dword", $iMode)     If @error Then Return SetError(1, 0, 0)     Return $aCall[0] EndFunc

Edited by trancexx, 13 January 2013 - 09:32 PM.

  • ZombieKillz and Xandy like this

Maybe I'm in love (Sshh, it's a secret)

.

 

eMyvnE


#8 kylomas

kylomas

    FUBAR

  • MVPs
  • 2,794 posts

Posted 14 January 2013 - 04:12 AM

trancexx,

When I run this with "seterrormode" commented out I do not get a windows error, just a -1 return from fileopen.

Script run in 32 bit mode on Win7 (64 bit) OS at current maint levels.

kylomas

"Really?, How Do you know the're not random numbers?"

 

Forum Rules         Procedure for posting code

 

"A child educated only at school is an uneducated child."

    - George Santayana

 

"Never miss a good chance to shut up."

    - Will Rogers
 


#9 trancexx

trancexx

    Queen F. Elizabeth MCXI

  • Active Members
  • PipPipPipPipPipPip
  • 5,969 posts

Posted 14 January 2013 - 06:54 AM

trancexx,

When I run this with "seterrormode" commented out I do not get a windows error, just a -1 return from fileopen.

Script run in 32 bit mode on Win7 (64 bit) OS at current maint levels.

kylomas

Why do I need to know that? I said what will happen for me, not you.

Maybe I'm in love (Sshh, it's a secret)

.

 

eMyvnE


#10 orbs

orbs

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 483 posts

Posted 14 January 2013 - 08:29 PM

thanks trancexx, this seems to be exactly what I was looking for! and thanks for the reference!

I added your code to my script, unfortunately I wasn't able to test it yet, because I first tried to reproduce the error with my original script - but my unstable hard drive has been behaving well all day! how frustrating, you just can't trust an untrusty hardware these days...

I will continue with my effort, and (hopefully) post some conclusions shortly.

many thanks again,
Or




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users