Files
winutil/functions/private/Get-WinUtilToggleStatus.ps1
T

41 lines
1.1 KiB
PowerShell
Raw Normal View History

Function Get-WinUtilToggleStatus ($ToggleSwitch) {
2026-05-19 14:11:27 -05:00
$ToggleSwitchReg = $sync.configs.tweaks.$ToggleSwitch.registry
2023-07-27 16:06:41 -05:00
if ($null -eq $sync.ToggleStatusCache) {
$sync.ToggleStatusCache = @{}
}
if ($sync.ToggleStatusCache.ContainsKey($ToggleSwitch)) {
return [bool]$sync.ToggleStatusCache[$ToggleSwitch]
}
if (-not (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS | Out-Null
}
+1
2023-11-14 15:45:48 -06:00
foreach ($regentry in $ToggleSwitchReg) {
2024-12-06 04:24:36 +01:00
if (Test-Path $regentry.Path) {
$regstate = (Get-ItemProperty -Path $regentry.Path).$($regentry.Name)
} else {
$regstate = $null
2024-12-06 04:24:36 +01:00
}
2026-05-19 21:13:27 +03:00
if ($null -eq $regstate) {
switch ([string]$regentry.DefaultState) {
"true" { $regstate = $regentry.Value }
"false" { $regstate = $regentry.OriginalValue }
2024-12-06 04:24:36 +01:00
}
}
2026-05-19 21:13:27 +03:00
if ($regstate -ne $regentry.Value) {
$sync.ToggleStatusCache[$ToggleSwitch] = $false
2024-12-06 04:24:36 +01:00
return $false
}
}
2026-05-19 21:13:27 +03:00
$sync.ToggleStatusCache[$ToggleSwitch] = $true
2026-05-19 21:13:27 +03:00
return $true
+1
2024-04-20 16:38:43 -05:00
}