Sign in to follow this  
Followers 0
dbpaquette

@error value returned from command line?

3 posts in this topic

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

Share this post


Link to post
Share on other sites



dbpaquette Welcom to autoit forum please type your autoit code in Code option.

post-76662-0-51470800-1382170247_thumb.p


Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

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.


√-1 2^3 ∑ π, and it was delicious!

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  
Followers 0