mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-04-05 22:28:31 +00:00
* Fix Get Installed toggle detection and multiple config bugs 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 * Fix toggles --------- Co-authored-by: Akhil Achanta <akhilachanta8@gmail.com>
145 lines
5.5 KiB
PowerShell
145 lines
5.5 KiB
PowerShell
Function Invoke-WinUtilCurrentSystem {
|
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
Checks to see what tweaks have already been applied and what programs are installed, and checks the according boxes
|
|
|
|
.EXAMPLE
|
|
Get-WinUtilCheckBoxes "WPFInstall"
|
|
|
|
#>
|
|
|
|
param(
|
|
$CheckBox
|
|
)
|
|
if ($CheckBox -eq "choco") {
|
|
$apps = (choco list | Select-String -Pattern "^\S+").Matches.Value
|
|
$filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "WPFInstall*"}
|
|
$sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} | ForEach-Object {
|
|
$dependencies = @($sync.configs.applications.$($psitem.Key).choco -split ";")
|
|
if ($dependencies -in $apps) {
|
|
Write-Output $psitem.name
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($checkbox -eq "winget") {
|
|
|
|
$originalEncoding = [Console]::OutputEncoding
|
|
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new()
|
|
$Sync.InstalledPrograms = winget list -s winget | Select-Object -skip 3 | ConvertFrom-String -PropertyNames "Name", "Id", "Version", "Available" -Delimiter '\s{2,}'
|
|
[Console]::OutputEncoding = $originalEncoding
|
|
|
|
$filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "WPFInstall*"}
|
|
$sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} | ForEach-Object {
|
|
$dependencies = @($sync.configs.applications.$($psitem.Key).winget -split ";")
|
|
|
|
if ($dependencies[-1] -in $sync.InstalledPrograms.Id) {
|
|
Write-Output $psitem.name
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($CheckBox -eq "tweaks") {
|
|
|
|
if (!(Test-Path 'HKU:\')) {$null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS)}
|
|
$ScheduledTasks = Get-ScheduledTask
|
|
|
|
$sync.configs.tweaks | Get-Member -MemberType NoteProperty | ForEach-Object {
|
|
|
|
$Config = $psitem.Name
|
|
#WPFEssTweaksTele
|
|
$entry = $sync.configs.tweaks.$Config
|
|
$registryKeys = $entry.registry
|
|
$scheduledtaskKeys = $entry.scheduledtask
|
|
$serviceKeys = $entry.service
|
|
$appxKeys = $entry.appx
|
|
$invokeScript = $entry.InvokeScript
|
|
$entryType = $entry.Type
|
|
|
|
if ($registryKeys -or $scheduledtaskKeys -or $serviceKeys) {
|
|
$Values = @()
|
|
|
|
if ($entryType -eq "Toggle") {
|
|
if (-not (Get-WinUtilToggleStatus $Config)) {
|
|
$values += $False
|
|
}
|
|
} else {
|
|
$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 ($tweak in $tweaks) {
|
|
$task = $ScheduledTasks | Where-Object {$($psitem.TaskPath + $psitem.TaskName) -like "\$($tweak.name)"}
|
|
|
|
if ($task) {
|
|
$actualValue = $task.State
|
|
$expectedValue = $tweak.State
|
|
if ($expectedValue -ne $actualValue) {
|
|
$values += $False
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Foreach ($tweaks in $serviceKeys) {
|
|
Foreach ($tweak in $tweaks) {
|
|
$Service = Get-Service -Name $tweak.Name
|
|
|
|
if ($Service) {
|
|
$actualValue = $Service.StartType
|
|
$expectedValue = $tweak.StartupType
|
|
if ($expectedValue -ne $actualValue) {
|
|
$values += $False
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($values -notcontains $false) {
|
|
Write-Output $Config
|
|
}
|
|
} else {
|
|
if ($invokeScript -or $appxKeys) {
|
|
Write-Debug "Skipping $Config in Get Installed: no detectable registry, scheduled task, or service state."
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|