Using exit codes as success criteria

Hey guys,

How would I go about defining specific exit codes as success criteria for a task?

For instance, for all our software distribution packages, we’d like the action to only show as completed if the exit code is 0 or 3010.

Thanks for your help,

Hello!

One option we have is to make the relevance of the fixlet such that it is only not-relevant if the application is actually installed. Uninstall Keys are normally added at the very end of the installation and so using a registry check is often a great way to find out if something is installed. This will work much better than exit codes.

To answer your question:

  1. You have a couple options – if you use “exit #” in an action but not on the last line of the action, the action will show as failed. You can do:

    if {exit code of action != 0 and exit code of action != 3010}
    exit {exit code of action}
    endif

  2. You can fail the action with continue if:

    continue if {exit code of action = 0 or exit code of action != 3010}

Hi @strawgate

Where exactly in the action script would I have to insert these lines?

Thanks,
Raphael

You’d put them right after the place you ran the external process to check its return item. The action would then be able to fail if the process did not terminate with the right exit code.

1 Like

That worked, thanks

We had to alter the action script mentioned above slightly

If you don’t use the action script as following it will stop at the first condition if it evaluates to false and not check any further

continue if {(exit code of action = 0) or (exit code of action = 3010)}

Thanks to @steini44

2 Likes

Sorry – i’ll edit my examples above. I misunderstood and thought we were failing on error code 0 and error code 3010!

Bill

1 Like

You might also want to flag the action as pending restart in case of 3010…

continue if {exit code of action = 0 or exit code of action = 3010}
if {exit code of action = 3010}
  action requires restart "reboot_for_my_package"
endif

That will leave the Action with the status “Pending Restart” instead of “Fixed” until the reboot occurs.

2 Likes