Adding Custom Exit Codes

I saw that you can use Execute-Process -IgnoreExitCodes <String>, but can you add a custom one? I have an app that spits out 129 which states “you must reboot”, which is not the typical 3010 code.

Also is there a way to make the bubble at the end say “you must reboot your machine”?

Thanks.

Hi Adam,
You can do both of those things with the toolkit.
You can first capture the exit code of your installation into a variable by using the -passthru parameter with the execute-process function. Then use the Exit-Script function, passing that value out of the script.

You can also use the show-balloontip function to create a custom balloon tip.
These functions and their uses are outlined in the documentation which comes with the toolkit when you download it.

Thank you for the reply! I understand how to do the first part. Second part I got lost on though haha.

The scenario is I am installing SAP 7.40 and it sometimes gives error 129 which just means to reboot, but since it doesn’t use 3010 like any normal app, it is considered a failed install.

So the goal is to have 129 behave like 3010 and give a restart prompt, balloon, etc.

Like Aman suggested above, do something like this:
$ReturnCode = Execute-Process -IgnoreExitCodes ‘129’ -PassThru
If ($ReturnCode.ExitCode -eq 129) {
Exit-Script -ExitCode 3010
}

This look correct?

<Perform Installation tasks here>

$ReturnCode = Execute-Process -Path ‘gui740_05_2-10013011.exe’ -Parameters ‘/noDLG’ -IgnoreExitCodes ‘129,145’ -PassThru
If ($ReturnCode.ExitCode -eq 129) {Exit-Script -ExitCode 3010}
If ($ReturnCode.ExitCode -eq 145) {Exit-Script -ExitCode 3010}

Not sure why it wont let me edit my post, but should I keep -IgnoreExitCodes in the above script? Is it required?

Thanks again!

-IgnoreExitCodes does not worked.
So tried : Execute-Process -ContinueOnError $True -Path
-ContinueOnError worked.

-IgnoreExitCodes turns the specified exit codes into a 0 for the function you used it on.

The code you posted seems incomplete or you are using an older version of the toolkit.

In older versions -ContinueOnError is used for ignoring all exit codes. In the new versions it is used for ignoring errors of the function itself and code within not the program youre starting.

You can change the main exit code of the toolkit through variable $mainExitCode