diff --git a/config/tweaks.json b/config/tweaks.json index 6cb43537..0dccf41c 100644 --- a/config/tweaks.json +++ b/config/tweaks.json @@ -3349,6 +3349,7 @@ "Name": "BingSearchEnabled", "Value": "1", "OriginalValue": "0", + "DefaultState": "true", "Type": "DWord" } ], @@ -3392,6 +3393,7 @@ "Name": "VerboseStatus", "Value": "1", "OriginalValue": "0", + "DefaultState": "false", "Type": "DWord" } ], @@ -3410,6 +3412,7 @@ "Name": "HideRecommendedSection", "Value": "0", "OriginalValue": "1", + "DefaultState": "true", "Type": "DWord" }, { @@ -3417,6 +3420,7 @@ "Name": "IsEducationEnvironment", "Value": "0", "OriginalValue": "1", + "DefaultState": "true", "Type": "DWord" }, { @@ -3424,6 +3428,7 @@ "Name": "HideRecommendedSection", "Value": "0", "OriginalValue": "1", + "DefaultState": "true", "Type": "DWord" } ], @@ -3442,6 +3447,7 @@ "Name": "WindowArrangementActive", "Value": "1", "OriginalValue": "0", + "DefaultState": "true", "Type": "String" } ], @@ -3460,6 +3466,7 @@ "Name": "EnableSnapAssistFlyout", "Value": "1", "OriginalValue": "0", + "DefaultState": "true", "Type": "DWord" } ], @@ -3488,6 +3495,7 @@ "Name": "SnapAssist", "Value": "1", "OriginalValue": "0", + "DefaultState": "true", "Type": "DWord" } ], @@ -3516,6 +3524,7 @@ "Name": "MouseSpeed", "Value": "1", "OriginalValue": "0", + "DefaultState": "true", "Type": "DWord" }, { @@ -3523,6 +3532,7 @@ "Name": "MouseThreshold1", "Value": "6", "OriginalValue": "0", + "DefaultState": "true", "Type": "DWord" }, { @@ -3530,6 +3540,7 @@ "Name": "MouseThreshold2", "Value": "10", "OriginalValue": "0", + "DefaultState": "true", "Type": "DWord" } ], @@ -3548,6 +3559,7 @@ "Name": "Flags", "Value": "510", "OriginalValue": "58", + "DefaultState": "true", "Type": "DWord" } ], @@ -3622,6 +3634,7 @@ "Name": "SearchboxTaskbarMode", "Value": "1", "OriginalValue": "0", + "DefaultState": "true", "Type": "DWord" } ], @@ -3640,6 +3653,7 @@ "Name": "ShowTaskViewButton", "Value": "1", "OriginalValue": "0", + "DefaultState": "true", "Type": "DWord" } ], @@ -3658,6 +3672,7 @@ "Name": "TaskbarDa", "Value": "1", "OriginalValue": "0", + "DefaultState": "true", "Type": "DWord" } ], @@ -3676,6 +3691,7 @@ "Name": "TaskbarAl", "Value": "1", "OriginalValue": "0", + "DefaultState": "true", "Type": "DWord" } ], @@ -3694,6 +3710,7 @@ "Name": "DisplayParameters", "Value": "1", "OriginalValue": "0", + "DefaultState": "false", "Type": "DWord" }, { @@ -3701,6 +3718,7 @@ "Name": "DisableEmoticon", "Value": "1", "OriginalValue": "0", + "DefaultState": "false", "Type": "DWord" } ], diff --git a/functions/private/Get-WinUtilToggleStatus.ps1 b/functions/private/Get-WinUtilToggleStatus.ps1 index 3b0d329d..7084813e 100644 --- a/functions/private/Get-WinUtilToggleStatus.ps1 +++ b/functions/private/Get-WinUtilToggleStatus.ps1 @@ -35,6 +35,9 @@ Function Get-WinUtilToggleStatus { foreach ($regentry in $ToggleSwitchReg) { try { + if (!(Test-Path $regentry.Path)) { + New-Item -Path $regentry.Path -Force | Out-Null + } $regstate = (Get-ItemProperty -path $regentry.Path).$($regentry.Name) if ($regstate -eq $regentry.Value) { $count += 1 @@ -42,8 +45,27 @@ Function Get-WinUtilToggleStatus { } else { Write-Debug "$($regentry.Name) is false (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))" } + if (!$regstate) { + write-host "missing $($regentry.Name)" + switch ($regentry.DefaultState) { + "true" { + write-host "true" + $regstate = $regentry.Value + $count += 1 + } + "false" { + write-host "false" + $regstate = $regentry.OriginalValue + } + default { + write-host "default" + Write-Error "Entry for $($regentry.Name) does not exist and no DefaultState is defined." + $regstate = $regentry.OriginalValue + } + } + } } catch { - Write-Error "An error occurred while accessing registry entry $($regentry.Path): $_" + Write-Error "An unexpected error occurred: $_" } }