VBS does not suport ErrorHandlers, and only options available are on Error ResumeNext and On Error Goto 0. However there is a solution - EventHandlers which I ignored so far:
http://support.smartbear.com/viewarticle/55502/I added EventHandler 'OnLogError':
'USEUNIT CommonScripts
'CommonScripts unit contains Subs and Functions used by other units, including MailErr and KillThemAll Sub
Sub
GameOver_OnLogError(Sender, LogParams)
'Take a screen shot of the active window.
Set Wshshell=CreateObject("Word.Basic")
WshShell.sendkeys"%{prtsc}"
'Send Keys seems to fail without a Proper Delay
Delay(500)
'Create PictureObject from Clipboard
Set PicObj = Sys.Clipboard
Call PicObj.SaveToFile("C:\ErrorPics\LastError.png")
'Send Email about error with prontscreen attached
Call MailErr(LogParams.AdditionalText, "GAME OVER - " & LogParams.MessageText)
'Kill all trash processes that might remain after error was logged
Call KillThemAll
'Stop
Runner.Stop(True)
End Sub