Jump to content
Sign in to follow this  

COM error handling works randomly

Recommended Posts


Hi. my com error handling works randomly, Like every second time it cathes if there's a error, if it couldn't connect to my site.

Global $url = IniRead(@scriptdir & "\file.exe", 'data', 'data', 'Null')
global $f = FileOpen(@TempDir & "\file.txt") ;upload 1
$read = FileRead($f)
$data = "Log=" & $read
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", $url, False)
$oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv: Gecko/2009042316 Firefox/3.0.10 (.NET CLR 4.0.20506)")
$oHTTP.SetRequestHeader("Referrer", "http://www.yahoo.com")
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
;$oReceived = $oHTTP.ResponseText
;MsgBox(4096, "", "file.exe have been generated")

Case $show

Case $help


Func MyErrFunc()
MsgBox(4096, "", "A test log could not be send - please ensure you have uploaded & defined the right path.")

Share this post

Link to post
Share on other sites

can i make some error handling with this? : $oReceived = $oHTTP.ResponseText

Share this post

Link to post
Share on other sites

COM error handling in AutoIt is quite simple.... the script just stops..... Unless you use your own error handling. After a COM call use code like..

if @error then
msgbox(0, "bla", "tell me something")

Tho, the actions taken can be whatever you wish. In my scripts I code verbose log writing, so errors are recorded in external logs (which I designed). Ayways, do a search in the AutoIt help and you'll find COM Reference, there's some good stuff in there.

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