diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 84bc570..81ba2ee 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -247,18 +247,22 @@ function Install-WingetAutoUpdate{ function Uninstall-WingetAutoUpdate{ 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 ($WingetUpdatePath)){ - Remove-Item $WingetUpdatePath -Force -Recurse + 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 "$WingetUpdatePath not found! Uninstallation failed!" -ForegroundColor Red + Write-host "$InstallLocation not found! Uninstallation failed!" -ForegroundColor Red } } catch{ diff --git a/Winget-AutoUpdate/WAU-Uninstall.ps1 b/Winget-AutoUpdate/WAU-Uninstall.ps1 new file mode 100644 index 0000000..1d05b84 --- /dev/null +++ b/Winget-AutoUpdate/WAU-Uninstall.ps1 @@ -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 +} \ No newline at end of file