Jump to content

Need help with MyErrFunc()


bratton
 Share

Recommended Posts

Hello,

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)

to

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

CODE

#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

Next

MsgBox (0,"", $szResults)

EndIf

WEnd

Func MyErrFunc()

Sleep (1000)

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

SetError(1)

Endfunc

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...