- load HKU if needed (for tweaks & GetToggleStatus)
- remove unneeded Invoke-WinUtilNumLock
- has loaded HKU does not load/not stay loaded
This commit is contained in:
MyDrift 2024-11-06 19:13:32 +01:00
parent a93d44a6dc
commit 5c2d5fae1e
4 changed files with 15 additions and 33 deletions

View File

@ -3310,10 +3310,14 @@
}
],
"InvokeScript": [
"Invoke-WinUtilExplorerRefresh"
"
Invoke-WinUtilExplorerRefresh
"
],
"UndoScript": [
"Invoke-WinUtilExplorerRefresh"
"
Invoke-WinUtilExplorerRefresh
"
],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/DarkMode"
},

View File

@ -16,6 +16,11 @@ Function Get-WinUtilToggleStatus {
$ToggleSwitchReg = $sync.configs.tweaks.$ToggleSwitch.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 ($ToggleSwitchReg) {
$count = 0

View File

@ -1,31 +0,0 @@
function Invoke-WinUtilNumLock {
<#
.SYNOPSIS
Disables/Enables NumLock on startup
.PARAMETER Enabled
Indicates whether to enable or disable Numlock on startup
#>
Param($Enabled)
try {
if ($Enabled -eq $false) {
Write-Host "Enabling Numlock on startup"
$value = 2
} else {
Write-Host "Disabling Numlock on startup"
$value = 0
}
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
$HKUPath = "HKU:\.Default\Control Panel\Keyboard"
$HKCUPath = "HKCU:\Control Panel\Keyboard"
Set-ItemProperty -Path $HKUPath -Name InitialKeyboardIndicators -Value $value
Set-ItemProperty -Path $HKCUPath -Name InitialKeyboardIndicators -Value $value
}
Catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
} catch {
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}

View File

@ -77,6 +77,10 @@ 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 (($psitem.Path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
write-host "Created HKU drive"
}
Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry)
}
}