globally fix HKU error & minimize console feedback

- fix HKU issue globally
- remove some console logs, change some others to write-debug
This commit is contained in:
MyDrift 2024-11-07 08:25:30 +01:00
parent feff1078d8
commit 667d96c397
4 changed files with 12 additions and 21 deletions

View File

@ -17,12 +17,11 @@ Function Get-WinUtilToggleStatus {
$ToggleSwitchReg = $sync.configs.tweaks.$ToggleSwitch.registry $ToggleSwitchReg = $sync.configs.tweaks.$ToggleSwitch.registry
if (($ToggleSwitchReg.path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) { if (($ToggleSwitchReg.path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {
$null = New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS $null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS)
write-host "Created HKU drive"
if (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue) { if (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue) {
Write-Host "HKU drive created successfully" -ForegroundColor Green Write-Debug "HKU drive created successfully"
} else { } else {
Write-Host "Failed to create HKU drive" Write-Debug "Failed to create HKU drive"
} }
} }
@ -30,21 +29,20 @@ Function Get-WinUtilToggleStatus {
$count = 0 $count = 0
foreach ($regentry in $ToggleSwitchReg) { foreach ($regentry in $ToggleSwitchReg) {
write-host "Checking $($regentry.path)"
$regstate = (Get-ItemProperty -path $regentry.Path).$($regentry.Name) $regstate = (Get-ItemProperty -path $regentry.Path).$($regentry.Name)
if ($regstate -eq $regentry.Value) { if ($regstate -eq $regentry.Value) {
$count += 1 $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 { } 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) { 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 return $true
} else { } else {
write-host "$($ToggleSwitchReg.Name) is false (count: $count)" Write-Debug "$($ToggleSwitchReg.Name) is false (count: $count)"
return $false return $false
} }
} else { } else {

View File

@ -43,7 +43,7 @@ Function Invoke-WinUtilCurrentSystem {
if($CheckBox -eq "tweaks") { 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 $ScheduledTasks = Get-ScheduledTask
$sync.configs.tweaks | Get-Member -MemberType NoteProperty | ForEach-Object { $sync.configs.tweaks | Get-Member -MemberType NoteProperty | ForEach-Object {

View File

@ -77,13 +77,12 @@ function Invoke-WinUtilTweaks {
if($sync.configs.tweaks.$CheckBox.registry) { if($sync.configs.tweaks.$CheckBox.registry) {
$sync.configs.tweaks.$CheckBox.registry | ForEach-Object { $sync.configs.tweaks.$CheckBox.registry | ForEach-Object {
Write-Debug "$($psitem.Name) and state is $($psitem.$($values.registry))" Write-Debug "$($psitem.Name) and state is $($psitem.$($values.registry))"
if (($ToggleSwitchReg.path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) { if (($psitem.Path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS $null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS)
write-host "Created HKU drive"
if (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue) { if (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue) {
Write-Host "HKU drive created successfully" Write-Debug "HKU drive created successfully"
} else { } 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) Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry)

View File

@ -194,12 +194,6 @@ function Invoke-WPFUIElements {
$sync[$entryInfo.Name].IsChecked = (Get-WinUtilToggleStatus $entryInfo.Name) $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({ $sync[$entryInfo.Name].Add_Checked({
[System.Object]$Sender = $args[0] [System.Object]$Sender = $args[0]
Invoke-WinUtilTweaks $sender.name Invoke-WinUtilTweaks $sender.name