dbpaquette Posted October 18, 2013 Posted October 18, 2013 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!!!
Starstar Posted October 19, 2013 Posted October 19, 2013 dbpaquette Welcom to autoit forum please type your autoit code in Code option. Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."
Moderators JLogan3o13 Posted October 21, 2013 Moderators Posted October 21, 2013 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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now