Created UseWhiteList option

pull/38/head
Romain 2022-04-05 12:38:54 +02:00
parent 8efc279a66
commit acc36bf2ad
1 changed files with 18 additions and 10 deletions

View File

@ -19,6 +19,9 @@ Do not run Winget-AutoUpdate after installation. By default, Winget-AutoUpdate i
.PARAMETER DisableWAUAutoUpdate .PARAMETER DisableWAUAutoUpdate
Disable Winget-AutoUpdate update checking. By default, WAU auto update if new version is available on Github. 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 .PARAMETER Uninstall
Remove scheduled tasks and scripts. Remove scheduled tasks and scripts.
@ -32,7 +35,8 @@ param(
[Parameter(Mandatory=$False)] [Alias('Path')] [String] $WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate", [Parameter(Mandatory=$False)] [Alias('Path')] [String] $WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate",
[Parameter(Mandatory=$False)] [Switch] $DoNotUpdate = $false, [Parameter(Mandatory=$False)] [Switch] $DoNotUpdate = $false,
[Parameter(Mandatory=$False)] [Switch] $DisableWAUAutoUpdate = $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{ function Install-WingetAutoUpdate{
try{ 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 #Copy files to location
if (!(Test-Path $WingetUpdatePath)){ if (!(Test-Path $WingetUpdatePath)){
New-Item -ItemType Directory -Force -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\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 # 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 & 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{
<?xml version="1.0"?> <?xml version="1.0"?>
<app> <app>
<WAUautoupdate>$(!($DisableWAUAutoUpdate))</WAUautoupdate> <WAUautoupdate>$(!($DisableWAUAutoUpdate))</WAUautoupdate>
<UseWAUWhiteList>$UseWhiteList</UseWAUWhiteList>
</app> </app>
"@ "@
$ConfigXML.Save("$WingetUpdatePath\config\config.xml") $ConfigXML.Save("$WingetUpdatePath\config\config.xml")