Delete entire Key in Mod Template/Functions too

pull/257/head
KnifMelti 2023-01-05 08:00:41 +01:00
parent 6301fd9622
commit 53113310c0
2 changed files with 9 additions and 3 deletions

View File

@ -22,7 +22,8 @@ $AddValue = ""
$AddTypeData = "" $AddTypeData = ""
$AddType = "" $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" #$DelKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
#$DelValue = "WAU_BypassListForUsers" #$DelValue = "WAU_BypassListForUsers"
$DelKey = "" $DelKey = ""
@ -50,7 +51,7 @@ if ($Lnk) {
if ($AddKey -and $AddValue -and $AddTypeData -and $AddType) { if ($AddKey -and $AddValue -and $AddTypeData -and $AddType) {
Add-ModsReg $AddKey $AddValue $AddTypeData $AddType Add-ModsReg $AddKey $AddValue $AddTypeData $AddType
} }
if ($DelKey -and $DelValue) { if ($DelKey) {
Remove-ModsReg $DelKey $DelValue Remove-ModsReg $DelKey $DelValue
} }
if ($DelFile) { if ($DelFile) {

View File

@ -146,8 +146,13 @@ function Add-ModsReg ($AddKey, $AddValue, $AddTypeData, $AddType) {
function Remove-ModsReg ($DelKey, $DelValue) { function Remove-ModsReg ($DelKey, $DelValue) {
if (Test-Path "$DelKey") { if (Test-Path "$DelKey") {
if (!$DelValue) {
Remove-Item $DelKey -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
}
else {
Remove-ItemProperty $DelKey -Name $DelValue -Force -ErrorAction SilentlyContinue | Out-Null Remove-ItemProperty $DelKey -Name $DelValue -Force -ErrorAction SilentlyContinue | Out-Null
} }
}
Return Return
} }