From 44c6ecc334aaea32dde8443026b8f4870e9dcb67 Mon Sep 17 00:00:00 2001 From: Marterich <47688561+Marterich@users.noreply.github.com> Date: Thu, 22 Aug 2024 18:19:39 +0200 Subject: [PATCH] Persist Choco Preference across program restarts --- scripts/main.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index c1d476f4..29867f4b 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -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" `