mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-05-24 22:56:17 +00:00
Continue or registry failures and show details after execution
This commit is contained in:
@@ -138,6 +138,8 @@ function ExecuteParameter {
|
|||||||
|
|
||||||
# Executes all selected parameters/features
|
# Executes all selected parameters/features
|
||||||
function ExecuteAllChanges {
|
function ExecuteAllChanges {
|
||||||
|
$script:RegistryImportFailures = 0
|
||||||
|
|
||||||
# Build list of actionable parameters (skip control params and data-only params)
|
# Build list of actionable parameters (skip control params and data-only params)
|
||||||
$actionableKeys = @()
|
$actionableKeys = @()
|
||||||
foreach ($paramKey in $script:Params.Keys) {
|
foreach ($paramKey in $script:Params.Keys) {
|
||||||
@@ -216,4 +218,9 @@ function ExecuteAllChanges {
|
|||||||
|
|
||||||
ExecuteParameter -paramKey $paramKey
|
ExecuteParameter -paramKey $paramKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($script:RegistryImportFailures -gt 0) {
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "$($script:RegistryImportFailures) registry import change(s) failed. See output above for details." -ForegroundColor Yellow
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,7 @@ function ImportRegistryFile {
|
|||||||
|
|
||||||
if (-not (Test-Path $regFilePath)) {
|
if (-not (Test-Path $regFilePath)) {
|
||||||
$errorMessage = "Unable to find registry file: $path ($regFilePath)"
|
$errorMessage = "Unable to find registry file: $path ($regFilePath)"
|
||||||
|
$script:RegistryImportFailures++
|
||||||
Write-Host "Error: $errorMessage" -ForegroundColor Red
|
Write-Host "Error: $errorMessage" -ForegroundColor Red
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
throw $errorMessage
|
throw $errorMessage
|
||||||
@@ -100,9 +101,9 @@ function ImportRegistryFile {
|
|||||||
Write-Host ""
|
Write-Host ""
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
$script:RegistryImportFailures++
|
||||||
Write-Host $_.Exception.Message -ForegroundColor Red
|
Write-Host $_.Exception.Message -ForegroundColor Red
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
throw
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if ($offlineHiveLoaded) {
|
if ($offlineHiveLoaded) {
|
||||||
|
|||||||
@@ -123,6 +123,8 @@ function Show-ApplyModal {
|
|||||||
$applyWindow.Dispatcher.BeginInvoke([System.Windows.Threading.DispatcherPriority]::Background, [action]{
|
$applyWindow.Dispatcher.BeginInvoke([System.Windows.Threading.DispatcherPriority]::Background, [action]{
|
||||||
try {
|
try {
|
||||||
ExecuteAllChanges
|
ExecuteAllChanges
|
||||||
|
|
||||||
|
$registryImportFailureCount = [int]$script:RegistryImportFailures
|
||||||
|
|
||||||
# Restart explorer if requested
|
# Restart explorer if requested
|
||||||
if ($RestartExplorer -and -not $script:CancelRequested) {
|
if ($RestartExplorer -and -not $script:CancelRequested) {
|
||||||
@@ -139,7 +141,7 @@ function Show-ApplyModal {
|
|||||||
Write-Host ""
|
Write-Host ""
|
||||||
if ($script:CancelRequested) {
|
if ($script:CancelRequested) {
|
||||||
Write-Host "Script execution was cancelled by the user. Some changes may not have been applied."
|
Write-Host "Script execution was cancelled by the user. Some changes may not have been applied."
|
||||||
} else {
|
} elseif ($registryImportFailureCount -eq 0) {
|
||||||
Write-Host "All changes have been applied successfully!"
|
Write-Host "All changes have been applied successfully!"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,6 +155,11 @@ function Show-ApplyModal {
|
|||||||
$script:ApplyCompletionIconEl.Foreground = [System.Windows.Media.SolidColorBrush]::new([System.Windows.Media.ColorConverter]::ConvertFromString("#e8912d"))
|
$script:ApplyCompletionIconEl.Foreground = [System.Windows.Media.SolidColorBrush]::new([System.Windows.Media.ColorConverter]::ConvertFromString("#e8912d"))
|
||||||
$script:ApplyCompletionTitleEl.Text = "Cancelled"
|
$script:ApplyCompletionTitleEl.Text = "Cancelled"
|
||||||
$script:ApplyCompletionMessageEl.Text = "Script execution was cancelled by the user."
|
$script:ApplyCompletionMessageEl.Text = "Script execution was cancelled by the user."
|
||||||
|
} elseif ($registryImportFailureCount -gt 0) {
|
||||||
|
$script:ApplyCompletionIconEl.Text = [char]0xE7BA
|
||||||
|
$script:ApplyCompletionIconEl.Foreground = [System.Windows.Media.SolidColorBrush]::new([System.Windows.Media.ColorConverter]::ConvertFromString("#e8912d"))
|
||||||
|
$script:ApplyCompletionTitleEl.Text = "Changes Applied with Errors"
|
||||||
|
$script:ApplyCompletionMessageEl.Text = "$registryImportFailureCount registry change(s) failed. See console for details."
|
||||||
} else {
|
} else {
|
||||||
$script:ApplyCompletionTitleEl.Text = "Changes Applied"
|
$script:ApplyCompletionTitleEl.Text = "Changes Applied"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user