From acc36bf2ad8fc046ff4e8241908ef7ee44b73b0f Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Tue, 5 Apr 2022 12:38:54 +0200 Subject: [PATCH] Created UseWhiteList option --- Winget-AutoUpdate-Install.ps1 | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 171f51c..7ee1479 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -19,6 +19,9 @@ Do not run Winget-AutoUpdate after installation. By default, Winget-AutoUpdate i .PARAMETER DisableWAUAutoUpdate Disable Winget-AutoUpdate update checking. By default, WAU auto update if new version is available on Github. +.PARAMETER UseWhiteList +Use White List instead of Black List. This setting will not create the "exclude_apps.txt" but "include_apps.txt" + .PARAMETER Uninstall Remove scheduled tasks and scripts. @@ -32,7 +35,8 @@ param( [Parameter(Mandatory=$False)] [Alias('Path')] [String] $WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate", [Parameter(Mandatory=$False)] [Switch] $DoNotUpdate = $false, [Parameter(Mandatory=$False)] [Switch] $DisableWAUAutoUpdate = $false, - [Parameter(Mandatory=$False)] [Switch] $Uninstall = $false + [Parameter(Mandatory=$False)] [Switch] $Uninstall = $false, + [Parameter(Mandatory=$False)] [Switch] $UseWhiteList = $false ) @@ -86,20 +90,23 @@ function Install-Prerequisites{ function Install-WingetAutoUpdate{ try{ - #Check if previous version location exists and delete - $OldWingetUpdatePath = $WingetUpdatePath.Replace("\Winget-AutoUpdate","\winget-update") - if (Test-Path ($OldWingetUpdatePath)){ - Remove-Item $OldWingetUpdatePath -Force -Recurse - } - Get-ScheduledTask -TaskName "Winget Update" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False - Get-ScheduledTask -TaskName "Winget Update Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False - #Copy files to location if (!(Test-Path $WingetUpdatePath)){ New-Item -ItemType Directory -Force -Path $WingetUpdatePath } Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue - Copy-Item -Path "$PSScriptRoot\excluded_apps.txt" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue + #White List or Black List apps + if ($UseWhiteList){ + if (Test-Path "$PSScriptRoot\included_apps.txt"){ + Copy-Item -Path "$PSScriptRoot\included_apps.txt" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue + } + else{ + New-Item -Path $WingetUpdatePath -Name "included_apps.txt" -ItemType "file" + } + } + else { + Copy-Item -Path "$PSScriptRoot\excluded_apps.txt" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue + } # Set dummy regkeys for notification name and icon & reg add "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /v DisplayName /t REG_EXPAND_SZ /d "Application Update" /f | Out-Null @@ -130,6 +137,7 @@ function Install-WingetAutoUpdate{ $(!($DisableWAUAutoUpdate)) + $UseWhiteList "@ $ConfigXML.Save("$WingetUpdatePath\config\config.xml")