Shell.Execute errorcode

Hi all,
This code returns me an error code number 1 while it works well by default if I don’t set the error handling! is this a bug or is there really an error somewhere?

Shell1.Execute ("/usr/sbin/spctl --status")
If Shell1.ErrorCode = 0 Then
ud = Shell1.ReadAll
msgbox(ud)
else
MsgBox("An Error " + Shell1.ErrorCode.ToString +" has occurred !")
End

Thanks

Hi,
Best practice is to store the error code into a variable and use the variable everywhere. It’s fairly possible the ErrorCode is a computed property and resets itself or changes each time you access it.
Does this make a difference in your case?

No, this is the only command that returns an error code among a dozen Shell commands that follow each other… and it’s still the same error code number 1.

I don’t know. It works well on my side.
FWIW: error code 1 won’t tell you much, as these binaries often return 0 (no error) or 1 (any error).

If you just run spctl --status from the Terminal, do you get any error?

No error from the Terminal.

use ExitCode instead of ErrorCode

(ExitCode) Already tried and no effect.
I succeeded by putting it in 1st position and the other Shell.Execute behind, and there it works! (probably a conflict)

try this in a method or so.
make sure you use what xojo advices you to use.
Result As String is what you need to get the entire result when mode is Synchronous

https://documentation.xojo.com/api/os/shell.html

Thanks @DerkJ,
it works well with your code. Even with ReadAll.
Cheer !