From ac7ef119e0805b8468b1735a47b6aaef7f33c8fb Mon Sep 17 00:00:00 2001 From: rbalsleyMSFT <53497092+rbalsleyMSFT@users.noreply.github.com> Date: Mon, 4 Aug 2025 17:21:34 -0700 Subject: [PATCH] Feat: Add option to ignore non-zero application exit codes Introduces a new feature allowing application installations to succeed regardless of their exit code. This is useful for installers that may return non-standard exit codes which should be treated as successful. Changes include: - A new checkbox in the UI to enable this option for an application. - Updates to the application installation script to handle the new setting. - Modifications to save and load this setting in the application list. --- .../Apps/Orchestration/Install-Win32Apps.ps1 | 18 +++++++-- FFUDevelopment/BuildFFUVM_UI.xaml | 4 ++ .../FFUUI.Core/FFUUI.Core.Applications.psm1 | 37 ++++++++++++++----- .../FFUUI.Core/FFUUI.Core.Initialize.psm1 | 1 + 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/FFUDevelopment/Apps/Orchestration/Install-Win32Apps.ps1 b/FFUDevelopment/Apps/Orchestration/Install-Win32Apps.ps1 index cf70a44..83c0a9b 100644 --- a/FFUDevelopment/Apps/Orchestration/Install-Win32Apps.ps1 +++ b/FFUDevelopment/Apps/Orchestration/Install-Win32Apps.ps1 @@ -15,8 +15,10 @@ function Invoke-Process { [bool]$Wait = $true, [Parameter()] - [string[]]$AdditionalSuccessCodes + [string[]]$AdditionalSuccessCodes, + [Parameter()] + [bool]$IgnoreNonZeroExitCodes = $false ) $ErrorActionPreference = 'Stop' @@ -51,8 +53,12 @@ function Invoke-Process { $exitCode = $p.ExitCode # An exit code of 0 is always a success if ($exitCode -ne 0) { + # If IgnoreNonZeroExitCodes is true, treat any non-zero exit code as a success + if ($IgnoreNonZeroExitCodes) { + Write-Host "Ignoring non-zero exit code $exitCode because IgnoreNonZeroExitCodes is set to true." + } # Check if the non-zero exit code is in the list of additional success codes - if ($null -eq $AdditionalSuccessCodes -or $exitCode -notin $AdditionalSuccessCodes) { + elseif ($null -eq $AdditionalSuccessCodes -or $exitCode -notin $AdditionalSuccessCodes) { if ($cmdError) { throw $cmdError.Trim() } @@ -152,8 +158,14 @@ function Install-Applications { Write-Host "Additional success exit codes for $($app.Name): $($additionalSuccessCodes -join ', ')" } + # Check for IgnoreNonZeroExitCodes + $ignoreNonZeroExitCodes = $false + if ($app.PSObject.Properties['IgnoreNonZeroExitCodes'] -and $app.IgnoreNonZeroExitCodes -is [bool]) { + $ignoreNonZeroExitCodes = $app.IgnoreNonZeroExitCodes + } + Write-Host "Running command: $($app.CommandLine) $($argumentsToPass -join ' ')" - $result = Invoke-Process -FilePath $($app.CommandLine) -ArgumentList $argumentsToPass -AdditionalSuccessCodes $additionalSuccessCodes + $result = Invoke-Process -FilePath $($app.CommandLine) -ArgumentList $argumentsToPass -AdditionalSuccessCodes $additionalSuccessCodes -IgnoreNonZeroExitCodes $ignoreNonZeroExitCodes Write-Host "$($app.Name) exited with exit code: $($result.ExitCode)`r`n" } catch { Write-Error "Error occurred while installing $($app.Name): $_" diff --git a/FFUDevelopment/BuildFFUVM_UI.xaml b/FFUDevelopment/BuildFFUVM_UI.xaml index a1e733a..fa3ebe9 100644 --- a/FFUDevelopment/BuildFFUVM_UI.xaml +++ b/FFUDevelopment/BuildFFUVM_UI.xaml @@ -377,6 +377,9 @@ + + +