mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-06-28 00:54:47 -05:00
[FEAT] Remove Start Menu Recommendations / Fix GetToggle Logic (#3089)
* add WPFToggleRemoveRecommended - add WPFToggleStartMenuRecommendations - add reg entrys to modify for toggle - add non working link bc devdocs are broken in general * add iseducationenvironment notice * improve handling if entry does not exist - add DefaultState property - add handler for DefaultState in Get-WinUtilToggleStatus * remove helper console logs * fix search defaultstate * added missing default states
This commit is contained in:
@ -35,6 +35,9 @@ Function Get-WinUtilToggleStatus {
|
||||
|
||||
foreach ($regentry in $ToggleSwitchReg) {
|
||||
try {
|
||||
if (!(Test-Path $regentry.Path)) {
|
||||
New-Item -Path $regentry.Path -Force | Out-Null
|
||||
}
|
||||
$regstate = (Get-ItemProperty -path $regentry.Path).$($regentry.Name)
|
||||
if ($regstate -eq $regentry.Value) {
|
||||
$count += 1
|
||||
@ -42,8 +45,23 @@ Function Get-WinUtilToggleStatus {
|
||||
} else {
|
||||
Write-Debug "$($regentry.Name) is false (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))"
|
||||
}
|
||||
if (!$regstate) {
|
||||
switch ($regentry.DefaultState) {
|
||||
"true" {
|
||||
$regstate = $regentry.Value
|
||||
$count += 1
|
||||
}
|
||||
"false" {
|
||||
$regstate = $regentry.OriginalValue
|
||||
}
|
||||
default {
|
||||
Write-Error "Entry for $($regentry.Name) does not exist and no DefaultState is defined."
|
||||
$regstate = $regentry.OriginalValue
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
Write-Error "An error occurred while accessing registry entry $($regentry.Path): $_"
|
||||
Write-Error "An unexpected error occurred: $_"
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user