Skip to content

Commit 39eae61

Browse files
committed
Fix Get Installed toggle detection for issue ChrisTitusTech#3762
This commit addresses the issue where "Get Installed" in the Tweaks tab was not correctly pulling all toggle states, as reported in issue ChrisTitusTech#3762. Changes: 1. Invoke-WinUtilCurrentSystem now uses Get-WinUtilToggleStatus for Toggle-type tweaks to ensure consistent state detection 2. Added DefaultState-aware registry checking for non-Toggle tweaks 3. Fixed null check bug: Changed from `if(!$regstate)` to `if($null -eq $regstate)` to prevent registry values of 0 from being treated as missing (applies to both files) 4. Added debug logging for tweaks that only have InvokeScript or appx entries (not detectable by system state) The fix ensures "Get Installed" results match the initial toggle states shown in the UI, resolving the inconsistency reported in the issue. Fixes ChrisTitusTech#3762
1 parent b94e8c4 commit 39eae61

2 files changed

Lines changed: 47 additions & 13 deletions

File tree

functions/private/Get-WinUtilToggleStatus.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Function Get-WinUtilToggleStatus {
4545
} else {
4646
Write-Debug "$($regentry.Name) is false (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))"
4747
}
48-
if (!$regstate) {
48+
if ($null -eq $regstate) {
4949
switch ($regentry.DefaultState) {
5050
"true" {
5151
$regstate = $regentry.Value

functions/private/Invoke-WinUtilCurrentSystem.ps1

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,57 @@ Function Invoke-WinUtilCurrentSystem {
5050

5151
$Config = $psitem.Name
5252
#WPFEssTweaksTele
53-
$registryKeys = $sync.configs.tweaks.$Config.registry
54-
$scheduledtaskKeys = $sync.configs.tweaks.$Config.scheduledtask
55-
$serviceKeys = $sync.configs.tweaks.$Config.service
53+
$entry = $sync.configs.tweaks.$Config
54+
$registryKeys = $entry.registry
55+
$scheduledtaskKeys = $entry.scheduledtask
56+
$serviceKeys = $entry.service
57+
$appxKeys = $entry.appx
58+
$invokeScript = $entry.InvokeScript
59+
$entryType = $entry.Type
5660

5761
if($registryKeys -or $scheduledtaskKeys -or $serviceKeys) {
5862
$Values = @()
5963

64+
if($entryType -eq "Toggle") {
65+
if(-not (Get-WinUtilToggleStatus $Config)) {
66+
$values += $False
67+
}
68+
} else {
69+
$registryMatchCount = 0
70+
$registryTotal = 0
6071

61-
Foreach ($tweaks in $registryKeys) {
62-
Foreach($tweak in $tweaks) {
72+
Foreach ($tweaks in $registryKeys) {
73+
Foreach($tweak in $tweaks) {
74+
$registryTotal++
75+
$regstate = $null
6376

64-
if(test-path $tweak.Path) {
65-
$actualValue = Get-ItemProperty -Name $tweak.Name -Path $tweak.Path -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $($tweak.Name)
66-
$expectedValue = $tweak.Value
67-
if ($expectedValue -notlike $actualValue) {
68-
$values += $False
77+
if(Test-Path $tweak.Path) {
78+
$regstate = Get-ItemProperty -Name $tweak.Name -Path $tweak.Path -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $($tweak.Name)
79+
}
80+
81+
if($null -eq $regstate) {
82+
switch ($tweak.DefaultState) {
83+
"true" {
84+
$regstate = $tweak.Value
85+
}
86+
"false" {
87+
$regstate = $tweak.OriginalValue
88+
}
89+
default {
90+
$regstate = $tweak.OriginalValue
91+
}
92+
}
93+
}
94+
95+
if ($regstate -eq $tweak.Value) {
96+
$registryMatchCount++
6997
}
70-
} else {
71-
$values += $False
7298
}
7399
}
100+
101+
if($registryTotal -gt 0 -and $registryMatchCount -ne $registryTotal) {
102+
$values += $False
103+
}
74104
}
75105

76106
Foreach ($tweaks in $scheduledtaskKeys) {
@@ -104,6 +134,10 @@ Function Invoke-WinUtilCurrentSystem {
104134
if($values -notcontains $false) {
105135
Write-Output $Config
106136
}
137+
} else {
138+
if($invokeScript -or $appxKeys) {
139+
Write-Debug "Skipping $Config in Get Installed: no detectable registry, scheduled task, or service state."
140+
}
107141
}
108142
}
109143
}

0 commit comments

Comments
 (0)