toasterking
12/4/2017 - 4:02 PM

Evaluate exit code of script to determine the next command to try

Evaluate exit code of script to determine the next command to try

// Execute something that returns exit code 666
wait cmd.exe exit 666

// Check the exit code of the command to decide whether to do something else in the action script.
// If the action script contains a download or prefetch command, this workaround using a parameter is needed due to a bug in the way BigFix evaluates action scripts before executing them.
// Source: https://forum.bigfix.com/t/if-exit-code-of-action-0/3284/2
parameter "Exitcode" = "{if exist exit code of action then exit code of action as string else "90210"}"
if {parameter "Exitcode" = "666"}
	// The exit code was 666, which probably means something, so do something in response.
	delete blahfile.exe
elseif {parameter "Exitcode" = "667"}
	// Do something else
	folder create "C:\blah"
else
	// Do yet something else
	folder delete "C:\blah"
endif