PARAMETER NoClean
parent
f7d7bc1d3e
commit
3519854f31
|
@ -25,6 +25,9 @@ Use White List instead of Black List. This setting will not create the "exclude_
|
|||
.PARAMETER Uninstall
|
||||
Remove scheduled tasks and scripts.
|
||||
|
||||
.PARAMETER NoClean
|
||||
Keep critical files when uninstalling
|
||||
|
||||
.PARAMETER NotificationLevel
|
||||
Specify the Notification level: Full (Default, displays all notification), SuccessOnly (Only displays notification for success) or None (Does not show any popup).
|
||||
|
||||
|
@ -46,6 +49,9 @@ Run WAU on metered connection. Default No.
|
|||
.EXAMPLE
|
||||
.\winget-install-and-update.ps1 -Silent -UpdatesAtLogon -UpdatesInterval Weekly
|
||||
|
||||
.EXAMPLE
|
||||
.\WAU-Uninstall.ps1 -Silent -Uninstall -NoClean
|
||||
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
|
@ -56,6 +62,7 @@ param(
|
|||
[Parameter(Mandatory = $False)] [Switch] $DisableWAUAutoUpdate = $false,
|
||||
[Parameter(Mandatory = $False)] [Switch] $RunOnMetered = $false,
|
||||
[Parameter(Mandatory = $False)] [Switch] $Uninstall = $false,
|
||||
[Parameter(Mandatory = $False)] [Switch] $NoClean = $false,
|
||||
[Parameter(Mandatory = $False)] [Switch] $UseWhiteList = $false,
|
||||
[Parameter(Mandatory = $False)] [ValidateSet("Full", "SuccessOnly", "None")] [String] $NotificationLevel = "Full",
|
||||
[Parameter(Mandatory = $False)] [Switch] $UpdatesAtLogon = $false,
|
||||
|
@ -171,13 +178,19 @@ function Install-WingetAutoUpdate {
|
|||
Write-Host "`nInstalling WAU..." -ForegroundColor Yellow
|
||||
|
||||
try {
|
||||
#Copy files to location (and clean old install, keeping critical files)
|
||||
#Copy files to location (and clean old install)
|
||||
if (!(Test-Path $WingetUpdatePath)) {
|
||||
New-Item -ItemType Directory -Force -Path $WingetUpdatePath | Out-Null
|
||||
}
|
||||
else {
|
||||
if (!$NoClean) {
|
||||
Remove-Item "$WingetUpdatePath\*" -Force -Recurse -Exclude "*.log"
|
||||
}
|
||||
else {
|
||||
#Keep critical files
|
||||
Get-ChildItem -Path $WingetUpdatePath -Exclude included_apps.txt,mods,logs | Remove-Item -Recurse -Force
|
||||
}
|
||||
}
|
||||
Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue
|
||||
|
||||
#White List or Black List apps
|
||||
|
@ -280,9 +293,16 @@ function Uninstall-WingetAutoUpdate {
|
|||
#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, keeping critical files
|
||||
#Check if installed location exists and delete
|
||||
if (Test-Path ($InstallLocation)) {
|
||||
|
||||
if (!$NoClean) {
|
||||
Remove-Item "$InstallLocation\*" -Force -Recurse -Exclude "*.log"
|
||||
}
|
||||
else {
|
||||
#Keep critical files
|
||||
Get-ChildItem -Path $InstallLocation -Exclude included_apps.txt,mods,logs | Remove-Item -Recurse -Force
|
||||
}
|
||||
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
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Uninstall Winget-AutoUpdate
|
||||
|
||||
.DESCRIPTION
|
||||
Uninstall Winget-AutoUpdate (DEFAULT: clean old install)
|
||||
https://github.com/Romanitho/Winget-AutoUpdate
|
||||
|
||||
.PARAMETER NoClean
|
||||
Uninstall Winget-AutoUpdate (keep critical files)
|
||||
|
||||
.EXAMPLE
|
||||
.\WAU-Uninstall.ps1 -NoClean
|
||||
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $False)] [Switch] $NoClean = $false
|
||||
)
|
||||
|
||||
Write-Host "`n"
|
||||
Write-Host "`t 888 888 d8888 888 888" -ForegroundColor Magenta
|
||||
Write-Host "`t 888 o 888 d88888 888 888" -ForegroundColor Magenta
|
||||
|
@ -16,9 +37,16 @@ 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, keeping critical files
|
||||
#Check if installed location exists and delete
|
||||
if (Test-Path ($InstallLocation)) {
|
||||
|
||||
if (!$NoClean) {
|
||||
Remove-Item "$InstallLocation\*" -Force -Recurse -Exclude "*.log"
|
||||
}
|
||||
else {
|
||||
#Keep critical files
|
||||
Get-ChildItem -Path $InstallLocation -Exclude included_apps.txt,mods,logs | Remove-Item -Recurse -Force
|
||||
}
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue