Completed uninstall feature

pull/80/head
Romain 2022-05-22 17:24:56 +02:00
parent 5811a02e2a
commit d8a7cb7c12
2 changed files with 30 additions and 3 deletions

View File

@ -247,18 +247,22 @@ function Install-WingetAutoUpdate{
function Uninstall-WingetAutoUpdate{ function Uninstall-WingetAutoUpdate{
try{ try{
#Get registry install location
$InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
#Check if installed location exists and delete #Check if installed location exists and delete
if (Test-Path ($WingetUpdatePath)){ if (Test-Path ($InstallLocation)){
Remove-Item $WingetUpdatePath -Force -Recurse Remove-Item $InstallLocation -Force -Recurse
Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
& reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null & reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null
& reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null
Write-host "Uninstallation succeeded!" -ForegroundColor Green Write-host "Uninstallation succeeded!" -ForegroundColor Green
Start-sleep 1 Start-sleep 1
} }
else { else {
Write-host "$WingetUpdatePath not found! Uninstallation failed!" -ForegroundColor Red Write-host "$InstallLocation not found! Uninstallation failed!" -ForegroundColor Red
} }
} }
catch{ catch{

View File

@ -0,0 +1,23 @@
try{
#Get registry install location
$InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
#Check if installed location exists and delete
if (Test-Path ($InstallLocation)){
Remove-Item $InstallLocation -Force -Recurse
Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
& reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null
& reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null
Write-host "Uninstallation succeeded!" -ForegroundColor Green
Start-sleep 1
}
else {
Write-host "$InstallLocation not found! Uninstallation failed!" -ForegroundColor Red
}
}
catch{
Write-host "`nUninstallation failed! Run as admin ?" -ForegroundColor Red
Start-sleep 1
}