Jump to content
Sign in to follow this  

Need help with MyErrFunc()

Recommended Posts



I have a pretty simple script that I need some help with. The problem is that I'm trying to get this script to stop executing without exiting when it encounters an error. If I run this as a compiled exe while connected to my domain, it works fine. If I'm disconnected from my domain, then I get my custom Error message (as expected). But I also get an AutoIt Error - "Line -1: Error: Error in expression."

What I'm trying to do is suppress the Line -1 error and also allow the GUI stay active. If I add Exit to MyErrFunc, I no longer get the Line -1 error, but I loose my GUI as well.

Any help would be greatly appreciated.

Another way to force this script to fail is to change the line:

$objUser = ObjGet("LDAP://" & $strUserDN)


$objUser = ObjGet("LDAP://" & $strUserDN & "error")


#include <guiconstants.au3>

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

dim $szResults, $arrGroups

GUICreate ("TEST", 300, 200)

$btn = GUICtrlCreateButton("group membership", 10,10, 110, 28)

GUISetState ()

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

If $msg = $btn Then

$objSysInfo = ObjCreate("ADSystemInfo")

$strUserDN = $objSysInfo.UserName

$objUser = ObjGet("LDAP://" & $strUserDN)

$arrGroups = $objUser.GetEx("memberOf")

For $strGroup In $arrGroups

$szResults = $szResults & $strGroup & @CRLF


MsgBox (0,"", $szResults)



Func MyErrFunc()

Sleep (1000)

MsgBox (48,"TEST", "Error... ")



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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.