***SOLVED*** Install fails if "PRE-INSTALL" can't execute its command

SOLVED
I resolved my issue by using the MSI product code for the app that needed to be uninstalled. Which turned out to be better because I saved 700MB of space in the package by not including the source of the old app.

Here is what I used

Execute-MSI -Action ‘Uninstall’ -Path ‘{Product code goes here}’

Thanks for the replies.
SOLVED

Hello,

I am trying to uninstall an old version of an app before installing the new one with this…
“Execute-Process -Path “$dirSupportFiles\AppName.exe” -Parameters ‘/X /S /v/qn’ -WindowsStyle Hidden”

This string works if the app is installed, but in cases where it isn’t installed the script fails with an “Execution failure 1605”.

Using an extracted .msi will work if the old app is installed or not. But I want to know how I can get an .exe to work in this way too.

Thank you for any advice.

You have a several options:

  1. Use an If statement using Get-InstalledApplication to only run the Uninstall if you can confirm that the old app is installed.

  2. Use the -IgnoreExitCodes switch on Execute-Process to ignore the specific error code

  3. Use the -ContinueOnError switch on Execute-Process to simply ignore all errors and continue.

Where would these switches go in here?

“Execute-Process -Path “$dirSupportFiles\AppName.exe” -Parameters ‘/X /S /v/qn’ -WindowsStyle Hidden”