mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-04-03 14:06:27 +00:00
Fix undo when using presets
This commit is contained in:
@@ -2,7 +2,13 @@
|
|||||||
function PrintPendingChanges {
|
function PrintPendingChanges {
|
||||||
$skippedParams = @()
|
$skippedParams = @()
|
||||||
$undoChanges = $script:Params.ContainsKey('Undo')
|
$undoChanges = $script:Params.ContainsKey('Undo')
|
||||||
|
|
||||||
|
if ($undoChanges) {
|
||||||
|
Write-Output "Win11Debloat will make the following changes to revert the selected settings to Windows defaults:"
|
||||||
|
}
|
||||||
|
else {
|
||||||
Write-Output "Win11Debloat will make the following changes:"
|
Write-Output "Win11Debloat will make the following changes:"
|
||||||
|
}
|
||||||
|
|
||||||
if ($script:Params['CreateRestorePoint']) {
|
if ($script:Params['CreateRestorePoint']) {
|
||||||
Write-Output "- $($script:Features['CreateRestorePoint'].Label)"
|
Write-Output "- $($script:Features['CreateRestorePoint'].Label)"
|
||||||
|
|||||||
@@ -336,11 +336,12 @@ foreach ($Param in $script:ControlParams) {
|
|||||||
|
|
||||||
# Guard: Undo mode requires at least one actionable, non-control parameter.
|
# Guard: Undo mode requires at least one actionable, non-control parameter.
|
||||||
if ($script:Params.ContainsKey('Undo')) {
|
if ($script:Params.ContainsKey('Undo')) {
|
||||||
|
$loadsSettingsFromPreset = $RunDefaults -or $RunDefaultsLite -or $RunSavedSettings
|
||||||
$undoTargets = @($script:Params.Keys | Where-Object {
|
$undoTargets = @($script:Params.Keys | Where-Object {
|
||||||
($script:ControlParams -notcontains $_) -and $_ -ne 'Apps' -and $_ -ne 'CreateRestorePoint'
|
($script:ControlParams -notcontains $_) -and $_ -ne 'Apps' -and $_ -ne 'CreateRestorePoint'
|
||||||
})
|
})
|
||||||
|
|
||||||
if ($undoTargets.Count -eq 0) {
|
if ($undoTargets.Count -eq 0 -and -not $loadsSettingsFromPreset) {
|
||||||
Write-Error "The -Undo parameter requires at least one setting/feature parameter to revert."
|
Write-Error "The -Undo parameter requires at least one setting/feature parameter to revert."
|
||||||
AwaitKeyToExit
|
AwaitKeyToExit
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user