Jump to content

Recommended Posts

Posted

Hi,

I would like to get the @error value from when you run a command that does not exist, as in the below code:

 ;intentionaly pass in an exe that is misspelled
 $CmdStatus = RunWait(@ComSpec & " /c " & "foo")
 $AtError = @error
 msgbox(48, "ERROR", "CmdStatus =" & $CmdStatus, 20)
 msgbox(48, "ERROR", "errorocde =" & $AtError, 20)
 If ($AtError <>0) Then
  $ScriptletExitCode = $AtError
  $ScriptletExitMessageStr = "Error running 'foo'."
  Return $ScriptletExitCode
 EndIf
 If ($CmdStatus <> 0) Then
  $ScriptletExitCode = $CmdStatus
  $ScriptletExitMessageStr = "Error from 'foo'."
  Return $ScriptletExitCode
 EndIf
 $ScriptletExitCode = $CmdStatus

In all cases I have tried @error=0, any help will be greatly appreciated.

Ideally I would like to capture the case where the command cannot be launched with the @error value, and then use the return code from the command to catch errors the program reports.

Thanks!!!

  • Moderators
Posted

The reason you're getting 0 is because AutoIt is doing exactly what you told it to do, open a command line and type in the command 'foo', so of course @error is not going to be set. Try running the application directly from AutoIt, rather than through command line; this way you can capture the @error information.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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
  • Recently Browsing   0 members

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