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

Hi, kind of new to the toolkit. I am in the same boat where I have an exit code I need the app to ignore or see as a success. To give some insight, I am using the toolkit to deploy Lenovo BIOS updates, but leveraging ThinInstaller. I put all the commands in a batch file then use the Execute-process to call the batch file. It works well on most devices, but some throw a 1073807364 which I have no clue how to address or what it means. I use Lenovo’s update retriever to pull the update packages, then I edit the installation settings to handle the reboots etc. I do see that error code in the update retriever, but it is just a return code, not a failure code. So, where in the toolkit can I put that code so it is not seen as an error? The code below is how I am calling the batch file.

## <Perform Installation tasks here>
         Execute-Process "INSTALL.cmd"

Based on a suggestion posted before, would this work in my script, or is this where it would go?

$ReturnCode = Execute-Process "INSTALL.cmd" -IgnoreExitCodes ‘1073807364’ -PassThru

I’m guessing your install CMD is not returning the exist code back to powershell.

You’d have to do Exit /B %Exitcode% inside your CMD.

BTW: this is a really clunky way to use PSADT. if you want to it do CMD, do use PSADT.

Hey, thanks for the response, but I am a bit confused so bear with me please. For the exit code variable %exitcode% does that need to be defined somewhere or is this a wildcard variable per se? I know what the exit /b means, just trying to understand the variable. Also, is that a typo in your last sentence? Seems to repeat itself when you say a clunky way to use PSADT. Did you mean to say if I want to use CMD then do NOT use PSADT?
Thanks again.

In CMD batch files, The Env var name would be %ERRORLEVEL%

I recommend Either:

  • Do your install in PowerShell in PSADT, without calling your CMD and hope it returns an %errorlevel%.

OR

  • Use CMD only (No PSADT)