From 667d96c3979d494e674adf91db549dd80381858c Mon Sep 17 00:00:00 2001 From: MyDrift Date: Thu, 7 Nov 2024 08:25:30 +0100 Subject: [PATCH] globally fix HKU error & minimize console feedback - fix HKU issue globally - remove some console logs, change some others to write-debug --- functions/private/Get-WinUtilToggleStatus.ps1 | 16 +++++++--------- .../private/Invoke-WinUtilCurrentSystem.ps1 | 2 +- functions/private/Invoke-WinUtilTweaks.ps1 | 9 ++++----- functions/public/Invoke-WPFUIElements.ps1 | 6 ------ 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/functions/private/Get-WinUtilToggleStatus.ps1 b/functions/private/Get-WinUtilToggleStatus.ps1 index 58a31dee..da222472 100644 --- a/functions/private/Get-WinUtilToggleStatus.ps1 +++ b/functions/private/Get-WinUtilToggleStatus.ps1 @@ -17,12 +17,11 @@ Function Get-WinUtilToggleStatus { $ToggleSwitchReg = $sync.configs.tweaks.$ToggleSwitch.registry if (($ToggleSwitchReg.path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) { - $null = New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS - write-host "Created HKU drive" + $null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS) if (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue) { - Write-Host "HKU drive created successfully" -ForegroundColor Green + Write-Debug "HKU drive created successfully" } else { - Write-Host "Failed to create HKU drive" + Write-Debug "Failed to create HKU drive" } } @@ -30,21 +29,20 @@ Function Get-WinUtilToggleStatus { $count = 0 foreach ($regentry in $ToggleSwitchReg) { - write-host "Checking $($regentry.path)" $regstate = (Get-ItemProperty -path $regentry.Path).$($regentry.Name) if ($regstate -eq $regentry.Value) { $count += 1 - write-host "$($regentry.Name) is true (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))" -ForegroundColor Green + Write-Debug "$($regentry.Name) is true (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))" } else { - write-host "$($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 ($count -eq $ToggleSwitchReg.Count) { - write-host "$($ToggleSwitchReg.Name) is true (count: $count)" -ForegroundColor Green + Write-Debug "$($ToggleSwitchReg.Name) is true (count: $count)" return $true } else { - write-host "$($ToggleSwitchReg.Name) is false (count: $count)" + Write-Debug "$($ToggleSwitchReg.Name) is false (count: $count)" return $false } } else { diff --git a/functions/private/Invoke-WinUtilCurrentSystem.ps1 b/functions/private/Invoke-WinUtilCurrentSystem.ps1 index e62568f4..82d7938f 100644 --- a/functions/private/Invoke-WinUtilCurrentSystem.ps1 +++ b/functions/private/Invoke-WinUtilCurrentSystem.ps1 @@ -43,7 +43,7 @@ Function Invoke-WinUtilCurrentSystem { if($CheckBox -eq "tweaks") { - if(!(Test-Path 'HKU:\')) {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 $sync.configs.tweaks | Get-Member -MemberType NoteProperty | ForEach-Object { diff --git a/functions/private/Invoke-WinUtilTweaks.ps1 b/functions/private/Invoke-WinUtilTweaks.ps1 index d64f4cd9..a6822111 100644 --- a/functions/private/Invoke-WinUtilTweaks.ps1 +++ b/functions/private/Invoke-WinUtilTweaks.ps1 @@ -77,13 +77,12 @@ function Invoke-WinUtilTweaks { if($sync.configs.tweaks.$CheckBox.registry) { $sync.configs.tweaks.$CheckBox.registry | ForEach-Object { Write-Debug "$($psitem.Name) and state is $($psitem.$($values.registry))" - if (($ToggleSwitchReg.path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) { - New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS - write-host "Created HKU drive" + if (($psitem.Path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) { + $null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS) if (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue) { - Write-Host "HKU drive created successfully" + Write-Debug "HKU drive created successfully" } else { - Write-Host "Failed to create HKU drive" + Write-Debug "Failed to create HKU drive" } } Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry) diff --git a/functions/public/Invoke-WPFUIElements.ps1 b/functions/public/Invoke-WPFUIElements.ps1 index 90fb8760..7ae64d3d 100644 --- a/functions/public/Invoke-WPFUIElements.ps1 +++ b/functions/public/Invoke-WPFUIElements.ps1 @@ -194,12 +194,6 @@ function Invoke-WPFUIElements { $sync[$entryInfo.Name].IsChecked = (Get-WinUtilToggleStatus $entryInfo.Name) - if ($sync[$entryInfo.Name].IsChecked) { - write-host "$($entryInfo.Name) is checked" -ForegroundColor Blue - } else { - write-host "$($entryInfo.Name) is not checked" -ForegroundColor Red - } - $sync[$entryInfo.Name].Add_Checked({ [System.Object]$Sender = $args[0] Invoke-WinUtilTweaks $sender.name