Persist Choco Preference across program restarts

This commit is contained in:
Marterich 2024-08-22 18:19:39 +02:00
parent a3ab1409e5
commit 44c6ecc334

View File

@ -87,6 +87,14 @@ try {
$xaml.SelectNodes("//*[@Name]") | ForEach-Object {$sync["$("$($psitem.Name)")"] = $sync["Form"].FindName($psitem.Name)}
#Persist the Chocolatey preference across winutil restarts
$ChocoPreferencePath = "$env:LOCALAPPDATA\winutil\preferChocolatey.ini"
$sync.WPFpreferChocolatey.Add_Checked({New-Item -Path $ChocoPreferencePath -Force })
$sync.WPFpreferChocolatey.Add_Unchecked({Remove-Item $ChocoPreferencePath -Force})
if (Test-Path $ChocoPreferencePath){
$sync.WPFpreferChocolatey.IsChecked = $true
}
$sync.keys | ForEach-Object {
if($sync.$psitem) {
if($($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "CheckBox" `