Fix Get Installed toggle detection and multiple config bugs (#3959)

Fixes the issue where "Get Installed" in the Tweaks tab was not correctly
pulling all toggle states, plus several additional config bugs discovered
during investigation.

Changes:
- Unified toggle detection logic using Get-WinUtilToggleStatus
- Fixed registry value detection (0 values were incorrectly treated as missing)
- Added DefaultState support for missing registry keys
- Fixed WPFTweaksUTC registry type (QWord → DWord)
- Fixed WPFTweaksServices startup types (TermService, VaultSvc: Automatic → Manual)
- Fixed duplicate order collisions in tweaks
- Fixed FFmpeg display name
- Improved OneDrive removal script reliability
- Improved Copilot removal script with wildcard pattern and null check
- Fixed code formatting (added spaces after if/Foreach statements)

Files changed:
- functions/private/Invoke-WinUtilCurrentSystem.ps1
- functions/private/Get-WinUtilToggleStatus.ps1
- config/tweaks.json
- config/applications.json

Fixes #3762
Fixes #3189
Fixes #3876
Potentially fixes #3008
Potentially fixes #3815
This commit is contained in:
Akhil Kumar Achanta
2026-02-10 14:29:50 -05:00
committed by GitHub
parent e68e190ff3
commit 414cd139e2
4 changed files with 76 additions and 41 deletions

View File

@@ -555,7 +555,7 @@
"ffmpeg": { "ffmpeg": {
"category": "Utilities", "category": "Utilities",
"choco": "na", "choco": "na",
"content": "eibol.FFmpegBatchAVConverter", "content": "FFmpeg Batch AV Converter",
"description": "FFmpeg Batch AV Converter is a universal audio and video encoder, that allows to use the full potential of ffmpeg command line with a few mouse clicks in a convenient GUI with drag and drop, progress information.", "description": "FFmpeg Batch AV Converter is a universal audio and video encoder, that allows to use the full potential of ffmpeg command line with a few mouse clicks in a convenient GUI with drag and drop, progress information.",
"link": "https://ffmpeg-batch.sourceforge.io/", "link": "https://ffmpeg-batch.sourceforge.io/",
"winget": "eibol.FFmpegBatchAVConverter" "winget": "eibol.FFmpegBatchAVConverter"

View File

@@ -665,7 +665,7 @@
}, },
{ {
"Name": "TermService", "Name": "TermService",
"StartupType": "Automatic", "StartupType": "Manual",
"OriginalType": "Manual" "OriginalType": "Manual"
}, },
{ {
@@ -725,7 +725,7 @@
}, },
{ {
"Name": "VaultSvc", "Name": "VaultSvc",
"StartupType": "Automatic", "StartupType": "Manual",
"OriginalType": "Manual" "OriginalType": "Manual"
}, },
{ {
@@ -1632,7 +1632,7 @@
{ {
"Path": "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation", "Path": "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation",
"Name": "RealTimeIsUniversal", "Name": "RealTimeIsUniversal",
"Type": "QWord", "Type": "DWord",
"Value": "1", "Value": "1",
"OriginalValue": "0" "OriginalValue": "0"
} }
@@ -1655,12 +1655,16 @@
# Some of OneDrive files use explorer, and OneDrive uses FileCoAuth # Some of OneDrive files use explorer, and OneDrive uses FileCoAuth
Write-Host \"Removing leftover OneDrive Files...\" Write-Host \"Removing leftover OneDrive Files...\"
Stop-Process -Name FileCoAuth,Explorer Stop-Process -Name FileCoAuth -ErrorAction SilentlyContinue
Remove-Item \"$Env:LocalAppData\\Microsoft\\OneDrive\" -Recurse -Force Remove-Item \"$Env:LocalAppData\\Microsoft\\OneDrive\" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item \"C:\\ProgramData\\Microsoft OneDrive\" -Recurse -Force Remove-Item \"C:\\ProgramData\\Microsoft OneDrive\" -Recurse -Force -ErrorAction SilentlyContinue
# Grant back permission to accses OneDrive folder # Restart Explorer
icacls $Env:OneDrive /grant \"Administrators:(D,DC)\" Start-Process explorer.exe
# Reset and grant full control permissions to OneDrive folder
icacls $Env:OneDrive /reset
icacls $Env:OneDrive /grant \"Administrators:(F)\"
" "
], ],
"UndoScript": [ "UndoScript": [
@@ -1676,7 +1680,7 @@
"Description": "Removes the Home from Explorer and sets This PC as default", "Description": "Removes the Home from Explorer and sets This PC as default",
"category": "z__Advanced Tweaks - CAUTION", "category": "z__Advanced Tweaks - CAUTION",
"panel": "1", "panel": "1",
"Order": "a029_", "Order": "a029a_",
"InvokeScript": [ "InvokeScript": [
" "
Remove-Item \"HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\{f874310e-b6b7-47dc-bc84-b9e6b38f5903}\" Remove-Item \"HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\{f874310e-b6b7-47dc-bc84-b9e6b38f5903}\"
@@ -1696,7 +1700,7 @@
"Description": "Removes the Gallery from Explorer and sets This PC as default", "Description": "Removes the Gallery from Explorer and sets This PC as default",
"category": "z__Advanced Tweaks - CAUTION", "category": "z__Advanced Tweaks - CAUTION",
"panel": "1", "panel": "1",
"Order": "a029_", "Order": "a030_",
"InvokeScript": [ "InvokeScript": [
" "
Remove-Item \"HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\{e88865ea-0e1c-4e20-9aa6-edcd0212c87c}\" Remove-Item \"HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\{e88865ea-0e1c-4e20-9aa6-edcd0212c87c}\"
@@ -2043,11 +2047,12 @@
Get-AppxPackage -AllUsers *Copilot* | Remove-AppxPackage -AllUsers Get-AppxPackage -AllUsers *Copilot* | Remove-AppxPackage -AllUsers
Get-AppxPackage -AllUsers Microsoft.MicrosoftOfficeHub | Remove-AppxPackage -AllUsers Get-AppxPackage -AllUsers Microsoft.MicrosoftOfficeHub | Remove-AppxPackage -AllUsers
$Appx = (Get-AppxPackage MicrosoftWindows.Client.CoreAI).PackageFullName $Appx = (Get-AppxPackage *MicrosoftWindows.Client.CoreAI*).PackageFullName
if ($Appx) {
$Sid = (Get-LocalUser $Env:UserName).Sid.Value $Sid = (Get-LocalUser $Env:UserName).Sid.Value
New-Item \"HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Appx\\AppxAllUserStore\\EndOfLife\\$Sid\\$Appx\" -Force New-Item \"HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Appx\\AppxAllUserStore\\EndOfLife\\$Sid\\$Appx\" -Force
Remove-AppxPackage $Appx Remove-AppxPackage $Appx
}
" "
], ],
"UndoScript": [ "UndoScript": [

View File

@@ -45,7 +45,7 @@ Function Get-WinUtilToggleStatus {
} else { } else {
Write-Debug "$($regentry.Name) is false (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))" Write-Debug "$($regentry.Name) is false (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))"
} }
if (!$regstate) { if ($null -eq $regstate) {
switch ($regentry.DefaultState) { switch ($regentry.DefaultState) {
"true" { "true" {
$regstate = $regentry.Value $regstate = $regentry.Value

View File

@@ -41,47 +41,73 @@ Function Invoke-WinUtilCurrentSystem {
} }
} }
if($CheckBox -eq "tweaks") { if ($CheckBox -eq "tweaks") {
if(!(Test-Path 'HKU:\')) {$null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS)} if (!(Test-Path 'HKU:\')) {$null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS)}
$ScheduledTasks = Get-ScheduledTask $ScheduledTasks = Get-ScheduledTask
$sync.configs.tweaks | Get-Member -MemberType NoteProperty | ForEach-Object { $sync.configs.tweaks | Get-Member -MemberType NoteProperty | ForEach-Object {
$Config = $psitem.Name $Config = $psitem.Name
#WPFEssTweaksTele #WPFEssTweaksTele
$registryKeys = $sync.configs.tweaks.$Config.registry $entry = $sync.configs.tweaks.$Config
$scheduledtaskKeys = $sync.configs.tweaks.$Config.scheduledtask $registryKeys = $entry.registry
$serviceKeys = $sync.configs.tweaks.$Config.service $scheduledtaskKeys = $entry.scheduledtask
$serviceKeys = $entry.service
$appxKeys = $entry.appx
$invokeScript = $entry.InvokeScript
$entryType = $entry.Type
if($registryKeys -or $scheduledtaskKeys -or $serviceKeys) { if ($registryKeys -or $scheduledtaskKeys -or $serviceKeys) {
$Values = @() $Values = @()
if ($entryType -eq "Toggle") {
Foreach ($tweaks in $registryKeys) { if (-not (Get-WinUtilToggleStatus $Config)) {
Foreach($tweak in $tweaks) {
if(test-path $tweak.Path) {
$actualValue = Get-ItemProperty -Name $tweak.Name -Path $tweak.Path -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $($tweak.Name)
$expectedValue = $tweak.Value
if ($expectedValue -eq "<RemoveEntry>") {
if ($null -ne $actualValue) {
$values += $False
}
} elseif ($expectedValue -notlike $actualValue) {
$values += $False $values += $False
} }
} else { } else {
$values += $False $registryMatchCount = 0
$registryTotal = 0
Foreach ($tweaks in $registryKeys) {
Foreach ($tweak in $tweaks) {
$registryTotal++
$regstate = $null
if (Test-Path $tweak.Path) {
$regstate = Get-ItemProperty -Name $tweak.Name -Path $tweak.Path -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $($tweak.Name)
} }
if ($null -eq $regstate) {
switch ($tweak.DefaultState) {
"true" {
$regstate = $tweak.Value
}
"false" {
$regstate = $tweak.OriginalValue
}
default {
$regstate = $tweak.OriginalValue
}
}
}
if ($regstate -eq $tweak.Value) {
$registryMatchCount++
}
}
}
if ($registryTotal -gt 0 -and $registryMatchCount -ne $registryTotal) {
$values += $False
} }
} }
Foreach ($tweaks in $scheduledtaskKeys) { Foreach ($tweaks in $scheduledtaskKeys) {
Foreach($tweak in $tweaks) { Foreach ($tweak in $tweaks) {
$task = $ScheduledTasks | Where-Object {$($psitem.TaskPath + $psitem.TaskName) -like "\$($tweak.name)"} $task = $ScheduledTasks | Where-Object {$($psitem.TaskPath + $psitem.TaskName) -like "\$($tweak.name)"}
if($task) { if ($task) {
$actualValue = $task.State $actualValue = $task.State
$expectedValue = $tweak.State $expectedValue = $tweak.State
if ($expectedValue -ne $actualValue) { if ($expectedValue -ne $actualValue) {
@@ -92,10 +118,10 @@ Function Invoke-WinUtilCurrentSystem {
} }
Foreach ($tweaks in $serviceKeys) { Foreach ($tweaks in $serviceKeys) {
Foreach($tweak in $tweaks) { Foreach ($tweak in $tweaks) {
$Service = Get-Service -Name $tweak.Name $Service = Get-Service -Name $tweak.Name
if($Service) { if ($Service) {
$actualValue = $Service.StartType $actualValue = $Service.StartType
$expectedValue = $tweak.StartupType $expectedValue = $tweak.StartupType
if ($expectedValue -ne $actualValue) { if ($expectedValue -ne $actualValue) {
@@ -105,9 +131,13 @@ Function Invoke-WinUtilCurrentSystem {
} }
} }
if($values -notcontains $false) { if ($values -notcontains $false) {
Write-Output $Config Write-Output $Config
} }
} else {
if ($invokeScript -or $appxKeys) {
Write-Debug "Skipping $Config in Get Installed: no detectable registry, scheduled task, or service state."
}
} }
} }
} }