Jump to content

Error lines display


francesco
 Share

Recommended Posts

I wrote a little exe that lets me make wmi calls, the problem that I have is that if an error is detected AutoIt displays the offending line in a message box, can I disable this, I would like to get just the error through the Exit () function.

Thanks in advance.

<{POST_SNAPBACK}>

it's an option you can use with Opt()

you you just want to use Opt("RunErrorsFatal",0)

RunErrorsFatal Sets if the script should terminate with a fatal error if a Run/RunWait function fails due to bad paths/file not found/Bad login IDs:

1 = fatal error (default)

0 = silent error (@error set to 1)

Link to comment
Share on other sites

Thanks but it did not work, I am attaching the code, when it fails it displays the line.

$sScheduleID = "{00000000-0000-0000-0000-000000000001}"

$oWMIservice = ObjGet("winmgmts:\\" & $MyCompName & "/root/ccm")

if @error = 0 then

$oInstance = $oWMIservice.Get("SMS_Client")

if @error = 0 then

$oParams = $oInstance.Methods_("TriggerSchedule").inParameters.SpawnInstance_()

if @error = 0 then

$oParams.sScheduleID = $sScheduleID

if @error = 0 then

$oWMIservice.ExecMethod("SMS_Client", "TriggerSchedule",$oParams) if @error = 0 Then

Exit

Else

Exit(1)

EndIf

EndIf

EndIf

EndIf

EndIf

Exit(1)

Link to comment
Share on other sites

Thanks but it did not work, I am attaching the code, when it fails it displays the line.

$sScheduleID = "{00000000-0000-0000-0000-000000000001}"

$oWMIservice =  ObjGet("winmgmts:\\" & $MyCompName  & "/root/ccm")

if @error = 0 then

  $oInstance = $oWMIservice.Get("SMS_Client")

  if @error = 0 then

  $oParams = $oInstance.Methods_("TriggerSchedule").inParameters.SpawnInstance_()

  if @error = 0 then

    $oParams.sScheduleID = $sScheduleID

    if @error = 0 then

    $oWMIservice.ExecMethod("SMS_Client", "TriggerSchedule",$oParams)    if @error = 0 Then

      Exit

    Else 

      Exit(1)

    EndIf

    EndIf

  EndIf

  EndIf

EndIf

Exit(1)

<{POST_SNAPBACK}>

what line is being displayed? could you take a screenshot of the error message? it may not be one that is generated by autoit
Link to comment
Share on other sites

I have attached screenshot

<{POST_SNAPBACK}>

did you add the:

Opt("RunErrorsFatal",0)

to the top of the script? also, another thing i noticed...

$oWMIservice.ExecMethod("SMS_Client", "TriggerSchedule",$oParams)    if @error = 0 Then

      Exit

    Else 

if the call is generating the error, the error would be handled (displayed or disregarded by the Opt()) prior to the execution of your condition check...
Link to comment
Share on other sites

Thanks but it did not work, I am attaching the code, when it fails it displays the line.

What you need is "COM Error Handling". Search the help file for that string and read the sample code.

In short, you install a new Error handling function.

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

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...