From 53113310c0a1c8042e6ac7abb7303d1807df0fc0 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Thu, 5 Jan 2023 08:00:41 +0100 Subject: [PATCH] Delete entire Key in Mod Template/Functions too --- Winget-AutoUpdate/mods/_AppID-template.ps1 | 5 +++-- Winget-AutoUpdate/mods/_Mods-Functions.ps1 | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Winget-AutoUpdate/mods/_AppID-template.ps1 b/Winget-AutoUpdate/mods/_AppID-template.ps1 index ef6392c..e7d942f 100644 --- a/Winget-AutoUpdate/mods/_AppID-template.ps1 +++ b/Winget-AutoUpdate/mods/_AppID-template.ps1 @@ -22,7 +22,8 @@ $AddValue = "" $AddTypeData = "" $AddType = "" -#Registry _value_ to delete in existing registry Key. Example: +#Registry _value_ to delete in existing registry Key. +#Value can be omitted for deleting entire Key!. Example: #$DelKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" #$DelValue = "WAU_BypassListForUsers" $DelKey = "" @@ -50,7 +51,7 @@ if ($Lnk) { if ($AddKey -and $AddValue -and $AddTypeData -and $AddType) { Add-ModsReg $AddKey $AddValue $AddTypeData $AddType } -if ($DelKey -and $DelValue) { +if ($DelKey) { Remove-ModsReg $DelKey $DelValue } if ($DelFile) { diff --git a/Winget-AutoUpdate/mods/_Mods-Functions.ps1 b/Winget-AutoUpdate/mods/_Mods-Functions.ps1 index a4202a2..569253e 100644 --- a/Winget-AutoUpdate/mods/_Mods-Functions.ps1 +++ b/Winget-AutoUpdate/mods/_Mods-Functions.ps1 @@ -146,7 +146,12 @@ function Add-ModsReg ($AddKey, $AddValue, $AddTypeData, $AddType) { function Remove-ModsReg ($DelKey, $DelValue) { if (Test-Path "$DelKey") { - Remove-ItemProperty $DelKey -Name $DelValue -Force -ErrorAction SilentlyContinue | Out-Null + if (!$DelValue) { + Remove-Item $DelKey -Recurse -Force -ErrorAction SilentlyContinue | Out-Null + } + else { + Remove-ItemProperty $DelKey -Name $DelValue -Force -ErrorAction SilentlyContinue | Out-Null + } } Return }