From 1217ac42828eb5868e0af6e68b02b6df9c6927e3 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Mon, 31 Oct 2022 20:55:58 +0100 Subject: [PATCH 01/36] -NoNewWindow -Wait so SCCM management is better --- install.bat | 2 +- uninstall.bat | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install.bat b/install.bat index 611ed89..868ae95 100644 --- a/install.bat +++ b/install.bat @@ -11,5 +11,5 @@ SET arguments=-UpdatesAtLogon -UpdatesInterval Weekly -InstallUserContext -Start :: Run Powershell Script :: :::::::::::::::::::::::::::: -SET PowershellCmd=Start-Process powershell.exe -Argument '-noprofile -executionpolicy bypass -file "%~dp0Winget-AutoUpdate-Install.ps1" %arguments% +SET PowershellCmd=Start-Process powershell.exe -NoNewWindow -Wait -Argument '-noprofile -executionpolicy bypass -file "%~dp0Winget-AutoUpdate-Install.ps1" %arguments% powershell -Command "& {Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; %PowershellCmd%'}" -Verb RunAs diff --git a/uninstall.bat b/uninstall.bat index 25a214a..341750b 100644 --- a/uninstall.bat +++ b/uninstall.bat @@ -11,5 +11,5 @@ SET arguments=-Uninstall :: Run Powershell Script :: :::::::::::::::::::::::::::: -SET PowershellCmd=Start-Process powershell.exe -Argument '-noprofile -executionpolicy bypass -file "%~dp0Winget-AutoUpdate-Install.ps1" %arguments% +SET PowershellCmd=Start-Process powershell.exe -NoNewWindow -Wait -Argument '-noprofile -executionpolicy bypass -file "%~dp0Winget-AutoUpdate-Install.ps1" %arguments% powershell -Command "& {Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; %PowershellCmd%'}" -Verb RunAs From 84f7e16f2a174656935f3393aac16c1619f6d8cd Mon Sep 17 00:00:00 2001 From: GAJ-san Date: Tue, 1 Nov 2022 11:12:06 +0100 Subject: [PATCH 02/36] -NoNewWindow -Wait Reverted --- install.bat | 2 +- uninstall.bat | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install.bat b/install.bat index 868ae95..611ed89 100644 --- a/install.bat +++ b/install.bat @@ -11,5 +11,5 @@ SET arguments=-UpdatesAtLogon -UpdatesInterval Weekly -InstallUserContext -Start :: Run Powershell Script :: :::::::::::::::::::::::::::: -SET PowershellCmd=Start-Process powershell.exe -NoNewWindow -Wait -Argument '-noprofile -executionpolicy bypass -file "%~dp0Winget-AutoUpdate-Install.ps1" %arguments% +SET PowershellCmd=Start-Process powershell.exe -Argument '-noprofile -executionpolicy bypass -file "%~dp0Winget-AutoUpdate-Install.ps1" %arguments% powershell -Command "& {Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; %PowershellCmd%'}" -Verb RunAs diff --git a/uninstall.bat b/uninstall.bat index 341750b..25a214a 100644 --- a/uninstall.bat +++ b/uninstall.bat @@ -11,5 +11,5 @@ SET arguments=-Uninstall :: Run Powershell Script :: :::::::::::::::::::::::::::: -SET PowershellCmd=Start-Process powershell.exe -NoNewWindow -Wait -Argument '-noprofile -executionpolicy bypass -file "%~dp0Winget-AutoUpdate-Install.ps1" %arguments% +SET PowershellCmd=Start-Process powershell.exe -Argument '-noprofile -executionpolicy bypass -file "%~dp0Winget-AutoUpdate-Install.ps1" %arguments% powershell -Command "& {Get-ChildItem -Path '%~dp0' -Recurse | Unblock-File; %PowershellCmd%'}" -Verb RunAs From db507c82640e1e1f7c954256c5ea7ab6a067530d Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 2 Nov 2022 18:47:21 +0100 Subject: [PATCH 03/36] Framework ready, function next --- README.md | 5 ++++- Winget-AutoUpdate-Install.ps1 | 10 ++++++++++ Winget-AutoUpdate/Winget-Upgrade.ps1 | 20 +++++++++++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8377d6a..aed80bc 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,10 @@ Disable Winget-AutoUpdate update checking. By default, WAU auto updates if new v Use White List instead of Black List. This setting will not create the "excluded_apps.txt" but "included_apps.txt" **-ListPath** -Get Black/White List from Path (URL/UNC/Local) (copy/download to Winget-AutoUpdate installation location if external list is newer). +Get Black/White List from Path (URL/UNC/Local) (download/copy to Winget-AutoUpdate installation location if external list is newer). + +**-ModsPath** +Get Mods from Path (URL/UNC/Local) (download/copy to `mods` in Winget-AutoUpdate installation location if external mods is newer). **-InstallUserContext** Install WAU with system and **user** context executions (From version 1.15.3) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 4173e0f..e0a0fa3 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -25,6 +25,9 @@ Use White List instead of Black List. This setting will not create the "exclude_ .PARAMETER ListPath Get Black/White List from Path (URL/UNC/Local) +.PARAMETER ModsPath +Get mods from Path (URL/UNC/Local) + .PARAMETER Uninstall Remove scheduled tasks and scripts. @@ -67,6 +70,9 @@ Configure WAU to bypass the Black/White list when run in user context .EXAMPLE .\Winget-AutoUpdate-Install.ps1 -Silent -ListPath https://www.domain.com/WAULists -StartMenuShortcut +.EXAMPLE +.\Winget-AutoUpdate-Install.ps1 -Silent -ModsPath https://www.domain.com/WAUMods -DesktopShortcut + .EXAMPLE .\Winget-AutoUpdate-Install.ps1 -Silent -UpdatesAtLogon -UpdatesInterval Weekly @@ -80,6 +86,7 @@ param( [Parameter(Mandatory = $False)] [Alias('S')] [Switch] $Silent = $false, [Parameter(Mandatory = $False)] [Alias('Path')] [String] $WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate", [Parameter(Mandatory = $False)] [Alias('List')] [String] $ListPath, + [Parameter(Mandatory = $False)] [Alias('Mods')] [String] $ModsPath, [Parameter(Mandatory = $False)] [Switch] $DoNotUpdate = $false, [Parameter(Mandatory = $False)] [Switch] $DisableWAUAutoUpdate = $false, [Parameter(Mandatory = $False)] [Switch] $RunOnMetered = $false, @@ -339,6 +346,9 @@ function Install-WingetAutoUpdate { if ($ListPath) { New-ItemProperty $regPath -Name WAU_ListPath -Value $ListPath -Force | Out-Null } + if ($ModsPath) { + New-ItemProperty $regPath -Name WAU_ModsPath -Value $ModsPath -Force | Out-Null + } if ($BypassListForUsers) { New-ItemProperty $regPath -Name WAU_BypassListForUsers -Value 1 -PropertyType DWord -Force | Out-Null } diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 75d4517..580dc46 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -76,7 +76,7 @@ if (Test-Network) { Write-Log "WAU uses External Lists from: $($WAUConfig.WAU_ListPath)" $NewList = Test-ListPath $WAUConfig.WAU_ListPath $WAUConfig.WAU_UseWhiteList $WAUConfig.InstallLocation if ($NewList) { - Write-Log "Newer List copied/downloaded to local path: $($WAUConfig.InstallLocation)" "Yellow" + Write-Log "Newer List downloaded/copied to local path: $($WAUConfig.InstallLocation)" "Yellow" } else { if ((Test-Path "$WorkingDir\included_apps.txt") -or (Test-Path "$WorkingDir\excluded_apps.txt")) { @@ -88,6 +88,24 @@ if (Test-Network) { } } } + + #Get External ModsPath if System + if ($WAUConfig.WAU_ModsPath) { + Write-Log "WAU uses External Mods from: $($WAUConfig.WAU_ModsPath)" + $NewMods = Test-ModsPath $WAUConfig.WAU_ModsPath $WAUConfig.InstallLocation + if ($NewMods) { + Write-Log "Newer Mods downloaded/copied to local path: $($WAUConfig.InstallLocation)" "Yellow" + } + else { + if (Test-Path "$WorkingDir\mods\*.ps1") { + Write-Log "Mods is up to date." "Green" + } + else { + Write-Log "Mods doesn't exist!" "Yellow" + #Exit 0 + } + } + } } #Get White or Black list From efc68d12cccf97dce0abf24ddd8195117c8ffdb9 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 2 Nov 2022 19:38:31 +0100 Subject: [PATCH 04/36] Function begun --- Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Winget-AutoUpdate/functions/Test-ModsPath.ps1 diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 new file mode 100644 index 0000000..190d85c --- /dev/null +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -0,0 +1,51 @@ +#Function to check Mods External Path + +function Test-ModsPath ($ModsPath, $WingetUpdatePath) { + # URL, UNC or Local Path + # Get local and external Mods paths + $LocalMods = -join ($WingetUpdatePath, "\", "mods") + $ExternalMods = "$ModsPath\" + + # Check if mods exists + if (Test-Path "$LocalMods\*.ps1") { + $dateLocal = (Get-Item "$LocalMods").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") + } + + # If path is URL + if ($ModsPath -like "http*") { + $ExternalMods = "$ModsPath/" + $wc = New-Object System.Net.WebClient + try { + $wc.OpenRead("$ExternalMods").Close() | Out-Null + $dateExternal = ([DateTime]$wc.ResponseHeaders['Last-Modified']).ToString("yyyy-MM-dd HH:mm:ss") + if ($dateExternal -gt $dateLocal) { + try { + $wc.DownloadFile($ExternalMods, $LocalMods) + } + catch { + return $False + } + return $true + } + } + catch { + return $False + } + } + # If path is UNC or local + else { + if (Test-Path -Path $ExternalMods -PathType leaf) { + $dateExternal = (Get-Item "$ExternalMods").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") + if ($dateExternal -gt $dateLocal) { + try { + Copy-Item $ExternalMods -Destination $LocalMods -Force + } + catch { + return $False + } + return $true + } + } + } + return $false +} From a25b01bca14061d0e52621d2e16b3b5faca0dcfb Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 2 Nov 2022 19:58:38 +0100 Subject: [PATCH 05/36] Text changes --- Winget-AutoUpdate/Winget-Upgrade.ps1 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 580dc46..be82612 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -94,15 +94,14 @@ if (Test-Network) { Write-Log "WAU uses External Mods from: $($WAUConfig.WAU_ModsPath)" $NewMods = Test-ModsPath $WAUConfig.WAU_ModsPath $WAUConfig.InstallLocation if ($NewMods) { - Write-Log "Newer Mods downloaded/copied to local path: $($WAUConfig.InstallLocation)" "Yellow" + Write-Log "Newer Mods downloaded/copied to local path: $($WAUConfig.InstallLocation)\mods" "Yellow" } else { if (Test-Path "$WorkingDir\mods\*.ps1") { - Write-Log "Mods is up to date." "Green" + Write-Log "Mods are up to date." "Green" } else { - Write-Log "Mods doesn't exist!" "Yellow" - #Exit 0 + Write-Log "Mods aren't implemented..." "Yellow" } } } From 518bcdf4dc6b0be9866700332a8d59cda797313c Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 2 Nov 2022 20:30:07 +0100 Subject: [PATCH 06/36] Text only --- Winget-AutoUpdate/Winget-Upgrade.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index be82612..e3d5222 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -101,7 +101,7 @@ if (Test-Network) { Write-Log "Mods are up to date." "Green" } else { - Write-Log "Mods aren't implemented..." "Yellow" + Write-Log "No Mods are implemented..." "Yellow" } } } From 0c1cf4aed0afebd0e6457b6d408b2a8b0dd20b52 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Thu, 3 Nov 2022 00:19:59 +0100 Subject: [PATCH 07/36] URL Remaining --- Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 47 ++++++++++++++----- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index 190d85c..ca5899e 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -4,12 +4,10 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { # URL, UNC or Local Path # Get local and external Mods paths $LocalMods = -join ($WingetUpdatePath, "\", "mods") - $ExternalMods = "$ModsPath\" - - # Check if mods exists - if (Test-Path "$LocalMods\*.ps1") { - $dateLocal = (Get-Item "$LocalMods").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") - } + $ExternalMods = "$ModsPath" + + #Get File Names Locally + $InternalModsNames = Get-ChildItem -Path $LocalMods -Name -Recurse -Include *.ps1 # If path is URL if ($ModsPath -like "http*") { @@ -34,18 +32,41 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { } # If path is UNC or local else { - if (Test-Path -Path $ExternalMods -PathType leaf) { - $dateExternal = (Get-Item "$ExternalMods").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") - if ($dateExternal -gt $dateLocal) { + #Get File Names Externally + $ExternalModsNames = Get-ChildItem -Path $ExternalMods -Name -Recurse -Include *.ps1 + if (Test-Path -Path $ExternalMods"\*.ps1") { + #Delete Local Mods that doesn't exist Externally + foreach ($Mod in $InternalModsNames){ try { - Copy-Item $ExternalMods -Destination $LocalMods -Force + If($Mod -notin $ExternalModsNames ){ + Remove-Item $LocalMods\$Mod -Force | Out-Null + } } catch { - return $False + #Do nothing } - return $true + } + try { + foreach ($Mod in $ExternalModsNames){ + if (Test-Path -Path $LocalMods"\"$Mod) { + $dateLocalMod = (Get-Item "$LocalMods\$Mod").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") + } + $dateExternalMod = (Get-Item "$ExternalMods\$Mod").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") + if ($dateExternalMod -gt $dateLocalMod) { + try { + Copy-Item $ExternalMods\$Mod -Destination $LocalMods\$Mod -Force + return $True + } + catch { + return $False + } + } + } + } + catch { + return $False } } } - return $false + return $False } From 231e6fa2f271fdcab8f088d839bd3e3f76de63ab Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Thu, 3 Nov 2022 01:19:04 +0100 Subject: [PATCH 08/36] Small fixes --- Winget-AutoUpdate/Winget-Upgrade.ps1 | 2 +- Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index e3d5222..d5d9c44 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -93,7 +93,7 @@ if (Test-Network) { if ($WAUConfig.WAU_ModsPath) { Write-Log "WAU uses External Mods from: $($WAUConfig.WAU_ModsPath)" $NewMods = Test-ModsPath $WAUConfig.WAU_ModsPath $WAUConfig.InstallLocation - if ($NewMods) { + if ($NewMods -gt 0) { Write-Log "Newer Mods downloaded/copied to local path: $($WAUConfig.InstallLocation)\mods" "Yellow" } else { diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index ca5899e..6d1d811 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -32,9 +32,9 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { } # If path is UNC or local else { - #Get File Names Externally - $ExternalModsNames = Get-ChildItem -Path $ExternalMods -Name -Recurse -Include *.ps1 if (Test-Path -Path $ExternalMods"\*.ps1") { + #Get File Names Externally + $ExternalModsNames = Get-ChildItem -Path $ExternalMods -Name -Recurse -Include *.ps1 #Delete Local Mods that doesn't exist Externally foreach ($Mod in $InternalModsNames){ try { @@ -55,17 +55,19 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { if ($dateExternalMod -gt $dateLocalMod) { try { Copy-Item $ExternalMods\$Mod -Destination $LocalMods\$Mod -Force - return $True + $ModsUpdated++ } catch { return $False } } } + } catch { return $False } + return $ModsUpdated } } return $False From 108df76229ec002b5b4809d702a8f925c4e10b7c Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Fri, 4 Nov 2022 00:09:53 +0100 Subject: [PATCH 09/36] ModsPath Done --- README.md | 1 + Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 55 +++++++++++++++---- 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index aed80bc..f542088 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ Get Black/White List from Path (URL/UNC/Local) (download/copy to Winget-AutoUpda **-ModsPath** Get Mods from Path (URL/UNC/Local) (download/copy to `mods` in Winget-AutoUpdate installation location if external mods is newer). +For URL: This requires a site with `Options +Indexes` in `.htaccess` and no index page overriding the listing of files or an index page with href listings of all the Mods to be downloaded! **-InstallUserContext** Install WAU with system and **user** context executions (From version 1.15.3) diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index 6d1d811..b8a9b96 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -10,25 +10,58 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { $InternalModsNames = Get-ChildItem -Path $LocalMods -Name -Recurse -Include *.ps1 # If path is URL - if ($ModsPath -like "http*") { - $ExternalMods = "$ModsPath/" + if ($ExternalMods -like "http*") { $wc = New-Object System.Net.WebClient - try { - $wc.OpenRead("$ExternalMods").Close() | Out-Null - $dateExternal = ([DateTime]$wc.ResponseHeaders['Last-Modified']).ToString("yyyy-MM-dd HH:mm:ss") - if ($dateExternal -gt $dateLocal) { + + # enable TLS 1.2 and TLS 1.1 protocols + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Tls11 + #Get Index of $ExternalMods (or index page with href listings of all the Mods) + $WebResponse = Invoke-WebRequest -Uri $ExternalMods + # Get the list of links, skip the first one ("../") if listing is allowed + $ModLinks = $WebResponse.Links | Select-Object -ExpandProperty href -Skip 1 + + #Delete Local Mods that doesn't exist Externally + foreach ($Mod in $InternalModsNames) { + try { + If ($Mod -notin $ModLinks) { + Remove-Item $LocalMods\$Mod -Force | Out-Null + } + } + catch { + #Do nothing + } + } + + #Loop through all links + $WebResponse.Links | Select-Object -ExpandProperty href -Skip 1 | ForEach-Object { + #Check for .ps1 in listing/HREF:s in an index page pointing to .ps1 + if ($_ -like "*.ps1") { try { - $wc.DownloadFile($ExternalMods, $LocalMods) + $wc.OpenRead("$ExternalMods/$_").Close() | Out-Null + $dateExternalMod = ([DateTime]$wc.ResponseHeaders['Last-Modified']).ToString("yyyy-MM-dd HH:mm:ss") + if (Test-Path -Path $LocalMods"\"$_) { + $dateLocalMod = (Get-Item "$LocalMods\$_").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") + } + + if ($dateExternalMod -gt $dateLocalMod) { + try { + $SaveMod = Join-Path -Path "$LocalMods\" -ChildPath $_ + $Mod = '{0}/{1}' -f $ModsPath.TrimEnd('/'), $_ + #Write-Host "Downloading file $dateExternal - $ExternalMods/$_ to $SaveMod" + Invoke-WebRequest -Uri "$Mod" -OutFile $SaveMod + $ModsUpdated++ + } + catch { + return $False + } + } } catch { return $False } - return $true } } - catch { - return $False - } + return $ModsUpdated } # If path is UNC or local else { From 991dd55c2f653219e9bb6164c97ed455959508e9 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Fri, 4 Nov 2022 00:40:29 +0100 Subject: [PATCH 10/36] Comment removed --- Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index b8a9b96..cd08e4a 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -47,7 +47,6 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { try { $SaveMod = Join-Path -Path "$LocalMods\" -ChildPath $_ $Mod = '{0}/{1}' -f $ModsPath.TrimEnd('/'), $_ - #Write-Host "Downloading file $dateExternal - $ExternalMods/$_ to $SaveMod" Invoke-WebRequest -Uri "$Mod" -OutFile $SaveMod $ModsUpdated++ } From 3262d11099fce5a0a1394032232fae1ebdebfdd4 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Fri, 4 Nov 2022 22:22:11 +0100 Subject: [PATCH 11/36] Error handling --- Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index cd08e4a..83fd286 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -16,22 +16,29 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { # enable TLS 1.2 and TLS 1.1 protocols [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Tls11 #Get Index of $ExternalMods (or index page with href listings of all the Mods) - $WebResponse = Invoke-WebRequest -Uri $ExternalMods - # Get the list of links, skip the first one ("../") if listing is allowed - $ModLinks = $WebResponse.Links | Select-Object -ExpandProperty href -Skip 1 - + try { + $WebResponse = Invoke-WebRequest -Uri $ExternalMods + } + catch { + return $False + } + #Delete Local Mods that doesn't exist Externally - foreach ($Mod in $InternalModsNames) { - try { - If ($Mod -notin $ModLinks) { - Remove-Item $LocalMods\$Mod -Force | Out-Null + if ($WebResponse) { + # Get the list of links, skip the first one ("../") if listing is allowed + $ModLinks = $WebResponse.Links | Select-Object -ExpandProperty href -Skip 1 + foreach ($Mod in $InternalModsNames) { + try { + If ($Mod -notin $ModLinks) { + Remove-Item $LocalMods\$Mod -Force | Out-Null + } + } + catch { + #Do nothing } } - catch { - #Do nothing - } } - + #Loop through all links $WebResponse.Links | Select-Object -ExpandProperty href -Skip 1 | ForEach-Object { #Check for .ps1 in listing/HREF:s in an index page pointing to .ps1 From 04dd756217210ba02fafc5084ef10732152968b5 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Fri, 4 Nov 2022 22:40:03 +0100 Subject: [PATCH 12/36] Cleaned --- Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index 83fd286..d61b53a 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -23,20 +23,18 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { return $False } + # Get the list of links, skip the first one ("../") if listing is allowed + $ModLinks = $WebResponse.Links | Select-Object -ExpandProperty href -Skip 1 #Delete Local Mods that doesn't exist Externally - if ($WebResponse) { - # Get the list of links, skip the first one ("../") if listing is allowed - $ModLinks = $WebResponse.Links | Select-Object -ExpandProperty href -Skip 1 - foreach ($Mod in $InternalModsNames) { - try { - If ($Mod -notin $ModLinks) { - Remove-Item $LocalMods\$Mod -Force | Out-Null - } - } - catch { - #Do nothing + foreach ($Mod in $InternalModsNames) { + try { + If ($Mod -notin $ModLinks) { + Remove-Item $LocalMods\$Mod -Force | Out-Null } } + catch { + #Do nothing + } } #Loop through all links From d73980ded5cce7d6d0e09c476a89e6454291373e Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 5 Nov 2022 01:12:13 +0100 Subject: [PATCH 13/36] Log Deleted Local Mods --- Winget-AutoUpdate/Winget-Upgrade.ps1 | 5 ++++- Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index d5d9c44..50415f0 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -92,7 +92,7 @@ if (Test-Network) { #Get External ModsPath if System if ($WAUConfig.WAU_ModsPath) { Write-Log "WAU uses External Mods from: $($WAUConfig.WAU_ModsPath)" - $NewMods = Test-ModsPath $WAUConfig.WAU_ModsPath $WAUConfig.InstallLocation + $NewMods, $DeletedMods = Test-ModsPath $WAUConfig.WAU_ModsPath $WAUConfig.InstallLocation if ($NewMods -gt 0) { Write-Log "Newer Mods downloaded/copied to local path: $($WAUConfig.InstallLocation)\mods" "Yellow" } @@ -104,6 +104,9 @@ if (Test-Network) { Write-Log "No Mods are implemented..." "Yellow" } } + if ($DeletedMods -gt 0) { + Write-Log "Deleted Local Mods (not externally managed): $DeletedMods" "Green" + } } } diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index d61b53a..40d4e88 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -30,6 +30,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { try { If ($Mod -notin $ModLinks) { Remove-Item $LocalMods\$Mod -Force | Out-Null + $DeletedMods++ } } catch { @@ -65,7 +66,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { } } } - return $ModsUpdated + return $ModsUpdated, $DeletedMods } # If path is UNC or local else { @@ -77,6 +78,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { try { If($Mod -notin $ExternalModsNames ){ Remove-Item $LocalMods\$Mod -Force | Out-Null + $DeletedMods++ } } catch { @@ -104,7 +106,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { catch { return $False } - return $ModsUpdated + return $ModsUpdated, $DeletedMods } } return $False From 145fec2204f44caf19c4337670ac62b2ead235a0 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 5 Nov 2022 12:52:58 +0100 Subject: [PATCH 14/36] Optimized ModsPath Function --- Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index 40d4e88..436ce0a 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -27,14 +27,9 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { $ModLinks = $WebResponse.Links | Select-Object -ExpandProperty href -Skip 1 #Delete Local Mods that doesn't exist Externally foreach ($Mod in $InternalModsNames) { - try { - If ($Mod -notin $ModLinks) { - Remove-Item $LocalMods\$Mod -Force | Out-Null - $DeletedMods++ - } - } - catch { - #Do nothing + If ($Mod -notin $ModLinks) { + Remove-Item $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null + $DeletedMods++ } } @@ -75,14 +70,9 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { $ExternalModsNames = Get-ChildItem -Path $ExternalMods -Name -Recurse -Include *.ps1 #Delete Local Mods that doesn't exist Externally foreach ($Mod in $InternalModsNames){ - try { - If($Mod -notin $ExternalModsNames ){ - Remove-Item $LocalMods\$Mod -Force | Out-Null - $DeletedMods++ - } - } - catch { - #Do nothing + If($Mod -notin $ExternalModsNames ){ + Remove-Item $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null + $DeletedMods++ } } try { @@ -92,13 +82,8 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { } $dateExternalMod = (Get-Item "$ExternalMods\$Mod").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") if ($dateExternalMod -gt $dateLocalMod) { - try { - Copy-Item $ExternalMods\$Mod -Destination $LocalMods\$Mod -Force - $ModsUpdated++ - } - catch { - return $False - } + Copy-Item $ExternalMods\$Mod -Destination $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null + $ModsUpdated++ } } @@ -108,6 +93,6 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { } return $ModsUpdated, $DeletedMods } + return $False } - return $False } From b921eb4307646e0e90376feee21827ebc34199d6 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 5 Nov 2022 17:45:34 +0100 Subject: [PATCH 15/36] Clarified README.md --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f542088..7092e0b 100644 --- a/README.md +++ b/README.md @@ -89,8 +89,15 @@ Use White List instead of Black List. This setting will not create the "excluded Get Black/White List from Path (URL/UNC/Local) (download/copy to Winget-AutoUpdate installation location if external list is newer). **-ModsPath** -Get Mods from Path (URL/UNC/Local) (download/copy to `mods` in Winget-AutoUpdate installation location if external mods is newer). -For URL: This requires a site with `Options +Indexes` in `.htaccess` and no index page overriding the listing of files or an index page with href listings of all the Mods to be downloaded! +Get Mods from Path (URL/UNC/Local) (download/copy to `mods` in Winget-AutoUpdate installation location if external mods is newer). +For URL: This requires a site with `Options +Indexes` in `.htaccess` and no index page overriding the listing of files. +Or an index page with href listings of all the Mods to be downloaded (with a first link to skip, emulating a directory list): +> **-InstallUserContext** Install WAU with system and **user** context executions (From version 1.15.3) From a4c11e85cccdb50380869ed7c98abdfcead76e9f Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 5 Nov 2022 17:47:13 +0100 Subject: [PATCH 16/36] md try 2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7092e0b..fc99f43 100644 --- a/README.md +++ b/README.md @@ -92,12 +92,12 @@ Get Black/White List from Path (URL/UNC/Local) (download/copy to Winget-AutoUpda Get Mods from Path (URL/UNC/Local) (download/copy to `mods` in Winget-AutoUpdate installation location if external mods is newer). For URL: This requires a site with `Options +Indexes` in `.htaccess` and no index page overriding the listing of files. Or an index page with href listings of all the Mods to be downloaded (with a first link to skip, emulating a directory list): -> ` **-InstallUserContext** Install WAU with system and **user** context executions (From version 1.15.3) From 07f84ccdb4b4a582781a29ae3b26d4f46711fd3a Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 5 Nov 2022 17:55:14 +0100 Subject: [PATCH 17/36] Corrected MarkDown... --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fc99f43..e77d045 100644 --- a/README.md +++ b/README.md @@ -92,12 +92,14 @@ Get Black/White List from Path (URL/UNC/Local) (download/copy to Winget-AutoUpda Get Mods from Path (URL/UNC/Local) (download/copy to `mods` in Winget-AutoUpdate installation location if external mods is newer). For URL: This requires a site with `Options +Indexes` in `.htaccess` and no index page overriding the listing of files. Or an index page with href listings of all the Mods to be downloaded (with a first link to skip, emulating a directory list): -> ` ` +``` + +``` **-InstallUserContext** Install WAU with system and **user** context executions (From version 1.15.3) From 711ba26db5d342a4c29ee158bc443fda873e1267 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 5 Nov 2022 18:22:55 +0100 Subject: [PATCH 18/36] Nicer list --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e77d045..ab66ef4 100644 --- a/README.md +++ b/README.md @@ -90,10 +90,11 @@ Get Black/White List from Path (URL/UNC/Local) (download/copy to Winget-AutoUpda **-ModsPath** Get Mods from Path (URL/UNC/Local) (download/copy to `mods` in Winget-AutoUpdate installation location if external mods is newer). -For URL: This requires a site with `Options +Indexes` in `.htaccess` and no index page overriding the listing of files. +For URL: This requires a site directory with `Options +Indexes` in `.htaccess` and no index page overriding the listing of files. Or an index page with href listings of all the Mods to be downloaded (with a first link to skip, emulating a directory list): ``` -
  • Parent Directory
  • +
      +
    • Parent Directory
    • Adobe.Acrobat.Reader.32-bit-install.ps1
    • Notepad++.Notepad++-install.ps1
    • Notepad++.Notepad++-uninstall.ps1
    • From 7039fa97a2554e9186d43d2f2d0804a1e600ef2a Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 5 Nov 2022 20:52:51 +0100 Subject: [PATCH 19/36] Don't Skip --- README.md | 3 +-- Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ab66ef4..be63816 100644 --- a/README.md +++ b/README.md @@ -91,10 +91,9 @@ Get Black/White List from Path (URL/UNC/Local) (download/copy to Winget-AutoUpda **-ModsPath** Get Mods from Path (URL/UNC/Local) (download/copy to `mods` in Winget-AutoUpdate installation location if external mods is newer). For URL: This requires a site directory with `Options +Indexes` in `.htaccess` and no index page overriding the listing of files. -Or an index page with href listings of all the Mods to be downloaded (with a first link to skip, emulating a directory list): +Or an index page with href listings of all the Mods to be downloaded: ```
        -
      • Parent Directory
      • Adobe.Acrobat.Reader.32-bit-install.ps1
      • Notepad++.Notepad++-install.ps1
      • Notepad++.Notepad++-uninstall.ps1
      • diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index 436ce0a..51e897f 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -23,8 +23,8 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { return $False } - # Get the list of links, skip the first one ("../") if listing is allowed - $ModLinks = $WebResponse.Links | Select-Object -ExpandProperty href -Skip 1 + # Collect the external list of href links + $ModLinks = $WebResponse.Links | Select-Object -ExpandProperty href #Delete Local Mods that doesn't exist Externally foreach ($Mod in $InternalModsNames) { If ($Mod -notin $ModLinks) { @@ -34,7 +34,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { } #Loop through all links - $WebResponse.Links | Select-Object -ExpandProperty href -Skip 1 | ForEach-Object { + $WebResponse.Links | Select-Object -ExpandProperty href | ForEach-Object { #Check for .ps1 in listing/HREF:s in an index page pointing to .ps1 if ($_ -like "*.ps1") { try { From bcb274b178887b34fd1ec9027666929ddadb8d54 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sun, 6 Nov 2022 06:37:34 +0100 Subject: [PATCH 20/36] Spelling --- README.md | 4 ++-- Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index be63816..5cf2de1 100644 --- a/README.md +++ b/README.md @@ -89,9 +89,9 @@ Use White List instead of Black List. This setting will not create the "excluded Get Black/White List from Path (URL/UNC/Local) (download/copy to Winget-AutoUpdate installation location if external list is newer). **-ModsPath** -Get Mods from Path (URL/UNC/Local) (download/copy to `mods` in Winget-AutoUpdate installation location if external mods is newer). +Get Mods from Path (URL/UNC/Local) (download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer). For URL: This requires a site directory with `Options +Indexes` in `.htaccess` and no index page overriding the listing of files. -Or an index page with href listings of all the Mods to be downloaded: +Or an index page with href listing of all the Mods to be downloaded: ```
        • Adobe.Acrobat.Reader.32-bit-install.ps1
        • diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index 51e897f..a289011 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -15,7 +15,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { # enable TLS 1.2 and TLS 1.1 protocols [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Tls11 - #Get Index of $ExternalMods (or index page with href listings of all the Mods) + #Get Index of $ExternalMods (or index page with href listing of all the Mods) try { $WebResponse = Invoke-WebRequest -Uri $ExternalMods } @@ -25,7 +25,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { # Collect the external list of href links $ModLinks = $WebResponse.Links | Select-Object -ExpandProperty href - #Delete Local Mods that doesn't exist Externally + #Delete Local Mods that don't exist Externally foreach ($Mod in $InternalModsNames) { If ($Mod -notin $ModLinks) { Remove-Item $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null @@ -68,7 +68,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { if (Test-Path -Path $ExternalMods"\*.ps1") { #Get File Names Externally $ExternalModsNames = Get-ChildItem -Path $ExternalMods -Name -Recurse -Include *.ps1 - #Delete Local Mods that doesn't exist Externally + #Delete Local Mods that don't exist Externally foreach ($Mod in $InternalModsNames){ If($Mod -notin $ExternalModsNames ){ Remove-Item $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null From fdfcdc98584020684db0fa9a676e2a215028654e Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Tue, 8 Nov 2022 01:09:52 +0100 Subject: [PATCH 21/36] Fix date and time check in loop --- Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index a289011..7dda8a5 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -38,6 +38,8 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { #Check for .ps1 in listing/HREF:s in an index page pointing to .ps1 if ($_ -like "*.ps1") { try { + $dateExternalMod = "" + $dateLocalMod ="" $wc.OpenRead("$ExternalMods/$_").Close() | Out-Null $dateExternalMod = ([DateTime]$wc.ResponseHeaders['Last-Modified']).ToString("yyyy-MM-dd HH:mm:ss") if (Test-Path -Path $LocalMods"\"$_) { From 7e631fd0a37b0499ed1240e8ba17ebf5677039cf Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Tue, 8 Nov 2022 03:21:48 +0100 Subject: [PATCH 22/36] Last fix and more log info --- Winget-AutoUpdate/Winget-Upgrade.ps1 | 2 +- Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 50415f0..0b18388 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -94,7 +94,7 @@ if (Test-Network) { Write-Log "WAU uses External Mods from: $($WAUConfig.WAU_ModsPath)" $NewMods, $DeletedMods = Test-ModsPath $WAUConfig.WAU_ModsPath $WAUConfig.InstallLocation if ($NewMods -gt 0) { - Write-Log "Newer Mods downloaded/copied to local path: $($WAUConfig.InstallLocation)\mods" "Yellow" + Write-Log "$NewMods newer Mods downloaded/copied to local path: $($WAUConfig.InstallLocation)\mods" "Yellow" } else { if (Test-Path "$WorkingDir\mods\*.ps1") { diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index 7dda8a5..3c6c463 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -79,6 +79,8 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { } try { foreach ($Mod in $ExternalModsNames){ + $dateExternalMod = "" + $dateLocalMod ="" if (Test-Path -Path $LocalMods"\"$Mod) { $dateLocalMod = (Get-Item "$LocalMods\$Mod").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") } From 0be2f416122af22aad713606025015b34723c45b Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Tue, 8 Nov 2022 03:41:31 +0100 Subject: [PATCH 23/36] Better log text --- Winget-AutoUpdate/Winget-Upgrade.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 0b18388..970e6b2 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -105,7 +105,7 @@ if (Test-Network) { } } if ($DeletedMods -gt 0) { - Write-Log "Deleted Local Mods (not externally managed): $DeletedMods" "Green" + Write-Log "$DeletedMods deleted Mods (not externally managed) from local path: $($WAUConfig.InstallLocation)\mods" "Red" } } } From 5c6c906180fb402b768180c192a65ad26ecfed97 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Tue, 8 Nov 2022 03:43:41 +0100 Subject: [PATCH 24/36] words mixed, tired... --- Winget-AutoUpdate/Winget-Upgrade.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Winget-AutoUpdate/Winget-Upgrade.ps1 index 970e6b2..cf79a12 100644 --- a/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -105,7 +105,7 @@ if (Test-Network) { } } if ($DeletedMods -gt 0) { - Write-Log "$DeletedMods deleted Mods (not externally managed) from local path: $($WAUConfig.InstallLocation)\mods" "Red" + Write-Log "$DeletedMods Mods deleted (not externally managed) from local path: $($WAUConfig.InstallLocation)\mods" "Red" } } } From 0d483a101263ab8c131b715ce268d0f9d6be78fd Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Tue, 15 Nov 2022 00:04:54 +0100 Subject: [PATCH 25/36] Fix -UseBasicParsing --- Winget-AutoUpdate/functions/Test-ModsPath.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 index 3c6c463..2ebc50d 100644 --- a/Winget-AutoUpdate/functions/Test-ModsPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ModsPath.ps1 @@ -17,7 +17,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Tls11 #Get Index of $ExternalMods (or index page with href listing of all the Mods) try { - $WebResponse = Invoke-WebRequest -Uri $ExternalMods + $WebResponse = Invoke-WebRequest -Uri $ExternalMods -UseBasicParsing } catch { return $False @@ -50,7 +50,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) { try { $SaveMod = Join-Path -Path "$LocalMods\" -ChildPath $_ $Mod = '{0}/{1}' -f $ModsPath.TrimEnd('/'), $_ - Invoke-WebRequest -Uri "$Mod" -OutFile $SaveMod + Invoke-WebRequest -Uri "$Mod" -OutFile $SaveMod -UseBasicParsing $ModsUpdated++ } catch { From 3211e53ca2487a5662aecb81423991dfe9d869c4 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Thu, 24 Nov 2022 21:05:40 +0100 Subject: [PATCH 26/36] BiDaily as choice for Schedule --- README.md | 2 +- Winget-AutoUpdate-Install.ps1 | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5cf2de1..4a56bc5 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ Specify the Notification level: Full (Default, displays all notification), Succe Set WAU to run at user logon. **-UpdatesInterval** -Specify the update frequency: Daily (Default), Weekly, Biweekly, Monthly or Never. Can be set to 'Never' in combination with '-UpdatesAtLogon' for instance +Specify the update frequency: Daily (Default), BiDaily, Weekly, Biweekly, Monthly or Never. Can be set to 'Never' in combination with '-UpdatesAtLogon' for instance **-UpdatesAtTime** Specify the time of the update interval execution time. Default 6AM. (From version 1.15.0) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index e0a0fa3..2c2a1e0 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -47,7 +47,7 @@ Specify the Notification level: Full (Default, displays all notification), Succe Set WAU to run at user logon. .PARAMETER UpdatesInterval -Specify the update frequency: Daily (Default), Weekly, Biweekly, Monthly or Never +Specify the update frequency: Daily (Default), BiDaily, Weekly, BiWeekly, Monthly or Never .PARAMETER UpdatesAtTime Specify the time of the update interval execution time. Default 6AM @@ -68,10 +68,10 @@ Configure WAU to bypass the Black/White list when run in user context .\Winget-AutoUpdate-Install.ps1 -Silent -UseWhiteList .EXAMPLE -.\Winget-AutoUpdate-Install.ps1 -Silent -ListPath https://www.domain.com/WAULists -StartMenuShortcut +.\Winget-AutoUpdate-Install.ps1 -Silent -ListPath https://www.domain.com/WAULists -StartMenuShortcut -UpdatesInterval BiDaily .EXAMPLE -.\Winget-AutoUpdate-Install.ps1 -Silent -ModsPath https://www.domain.com/WAUMods -DesktopShortcut +.\Winget-AutoUpdate-Install.ps1 -Silent -ModsPath https://www.domain.com/WAUMods -DesktopShortcut -UpdatesInterval Weekly .EXAMPLE .\Winget-AutoUpdate-Install.ps1 -Silent -UpdatesAtLogon -UpdatesInterval Weekly @@ -97,7 +97,7 @@ param( [Parameter(Mandatory = $False)] [Switch] $UseWhiteList = $false, [Parameter(Mandatory = $False)] [ValidateSet("Full", "SuccessOnly", "None")] [String] $NotificationLevel = "Full", [Parameter(Mandatory = $False)] [Switch] $UpdatesAtLogon = $false, - [Parameter(Mandatory = $False)] [ValidateSet("Daily", "Weekly", "BiWeekly", "Monthly", "Never")] [String] $UpdatesInterval = "Daily", + [Parameter(Mandatory = $False)] [ValidateSet("Daily", "BiDaily", "Weekly", "BiWeekly", "Monthly", "Never")] [String] $UpdatesInterval = "Daily", [Parameter(Mandatory = $False)] [DateTime] $UpdatesAtTime = ("06am"), [Parameter(Mandatory = $False)] [Switch] $BypassListForUsers = $false, [Parameter(Mandatory = $False)] [Switch] $InstallUserContext = $false @@ -272,6 +272,9 @@ function Install-WingetAutoUpdate { if ($UpdatesInterval -eq "Daily") { $tasktriggers += New-ScheduledTaskTrigger -Daily -At $UpdatesAtTime } + elseif ($UpdatesInterval -eq "BiDaily") { + $tasktriggers += New-ScheduledTaskTrigger -Daily -At $UpdatesAtTime -DaysInterval 2 + } elseif ($UpdatesInterval -eq "Weekly") { $tasktriggers += New-ScheduledTaskTrigger -Weekly -At $UpdatesAtTime -DaysOfWeek 2 } From 5eb55be98003da747e6b6442e1a292d10319e649 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Thu, 24 Nov 2022 21:17:54 +0100 Subject: [PATCH 27/36] Text everywhere --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4a56bc5..1ec5853 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ You can easily translate toast notifications by creating your locale xml config By default, scripts and components will be placed in ProgramData location (inside a Winget-AutoUpdate folder). You can change this with script argument (Not Recommended). ### When does the script run? -From version 1.9.0 (on new installations) WAU runs everyday at 6AM. You can now configure the frequency with `-UpdatesInterval` option (Daily, Weekly, Biweekly or Monthly). You can also add `-UpdatesAtLogon` parameter to run at user logon and keep this option activated like previous versions (recommanded). +From version 1.9.0 (on new installations) WAU runs everyday at 6AM. You can now configure the frequency with `-UpdatesInterval` option (Daily, BiDaily, Weekly, BiWeekly or Monthly). You can also add `-UpdatesAtLogon` parameter to run at user logon and keep this option activated like previous versions (recommanded). ### Log location You can find logs in install location, in logs folder. @@ -123,7 +123,7 @@ Specify the Notification level: Full (Default, displays all notification), Succe Set WAU to run at user logon. **-UpdatesInterval** -Specify the update frequency: Daily (Default), BiDaily, Weekly, Biweekly, Monthly or Never. Can be set to 'Never' in combination with '-UpdatesAtLogon' for instance +Specify the update frequency: Daily (Default), BiDaily, Weekly, BiWeekly, Monthly or Never. Can be set to 'Never' in combination with '-UpdatesAtLogon' for instance **-UpdatesAtTime** Specify the time of the update interval execution time. Default 6AM. (From version 1.15.0) From baa7ef84a4f488d0d89a438489a1d06336b455a9 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 26 Nov 2022 17:47:38 +0100 Subject: [PATCH 28/36] Adding PreInstall mods... --- Winget-AutoUpdate/functions/Test-Mods.ps1 | 6 +++++- Winget-AutoUpdate/functions/Update-App.ps1 | 12 +++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Winget-AutoUpdate/functions/Test-Mods.ps1 b/Winget-AutoUpdate/functions/Test-Mods.ps1 index b161847..e9177a1 100644 --- a/Winget-AutoUpdate/functions/Test-Mods.ps1 +++ b/Winget-AutoUpdate/functions/Test-Mods.ps1 @@ -3,11 +3,15 @@ function Test-Mods ($app) { #Takes care of a null situation + $ModsPreInstall = $null $ModsInstall = $null $ModsUpgrade = $null $Mods = "$WorkingDir\mods" if (Test-Path "$Mods\$app-*") { + if (Test-Path "$Mods\$app-preinstall.ps1") { + $ModsPreInstall = "$Mods\$app-preinstall.ps1" + } if (Test-Path "$Mods\$app-install.ps1") { $ModsInstall = "$Mods\$app-install.ps1" $ModsUpgrade = "$Mods\$app-install.ps1" @@ -17,6 +21,6 @@ function Test-Mods ($app) { } } - return $ModsInstall, $ModsUpgrade + return $ModsPreInstall, $ModsInstall, $ModsUpgrade } diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index efedd64..4a0d7f1 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -16,6 +16,15 @@ Function Update-App ($app) { $Balise = $($app.Name) Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Balise $Balise -Button1Action $ReleaseNoteURL -Button1Text $Button1Text + #Check if mods exist for preinstall/install/upgrade + $ModsPreInstall, $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) + + #If PreInstall script exist + if ($ModsPreInstall) { + Write-Log "Modifications for $($app.Id) before upgrade are being applied..." "Yellow" + & "$ModsPreInstall" + } + #Winget upgrade Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray" @@ -61,9 +70,6 @@ Function Update-App ($app) { if ($FailedToUpgrade -eq $false) { - #Check if mods exist for install/upgrade - $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) - if (($ModsUpgrade) -and ($ModsMode -eq "Upgrade")) { Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow" & "$ModsUpgrade" From 03adcfc3f11a0022f6a61141bcfd263ed58e501b Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 26 Nov 2022 21:58:52 +0100 Subject: [PATCH 29/36] Text --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1ec5853..42fe731 100644 --- a/README.md +++ b/README.md @@ -139,12 +139,13 @@ See https://github.com/Romanitho/Winget-AutoUpdate/discussions/88 ## Custom scripts (Mods feature) From version 1.8.0, the Mods feature allows you to run an additional script when upgrading or installing an app. -Just put the script in question with the App ID followed by the `-upgrade` or `-install` suffix in the "mods" folder. -WAU will call `AppID-upgrade.ps1` and/or `AppID-install.ps1` (if they differs, otherwise the "-install" mod will be used for upgrades too) if it exists in the "mods" folder just after the upgrade/install. +Just put the script in question with the App ID followed by the `-preinstall`, `-install` or `-upgrade` suffix in the **mods** folder. +WAU will call `AppID-preinstall.ps1` before **winget** upgrades the app. +WAU will call `AppID-install.ps1` and/or `AppID-upgrade.ps1` (if the install modes differs, otherwise the **-install** mod will be used for upgrades too) if it exists in the **mods** folder just after the upgrade/install. > Example: -If you want to run a script that removes the shortcut from "%PUBLIC%\Desktop" (we don't want to fill the desktop with shortcuts our users can't delete) just after installing "Acrobat Reader DC" (32-bit), prepare a powershell script that removes the Public Desktop shortcut "Acrobat Reader DC.lnk" and name your script like this: -`Adobe.Acrobat.Reader.32-bit-install.ps1` and put it in the "mods" folder. +If you want to run a script that removes the shortcut from **%PUBLIC%\Desktop** (we don't want to fill the desktop with shortcuts our users can't delete) just after installing **Acrobat Reader DC** (32-bit), prepare a powershell script that removes the Public Desktop shortcut **Acrobat Reader DC.lnk** and name your script like this: +`Adobe.Acrobat.Reader.32-bit-install.ps1` and put it in the **mods** folder. You can find more information on Winget-Install Repo, as it's a related feature From 1244374c34fa8dc49f8465080592541252aba9fa Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 26 Nov 2022 22:05:34 +0100 Subject: [PATCH 30/36] Text --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 42fe731..2d30d8f 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ See https://github.com/Romanitho/Winget-AutoUpdate/discussions/88 ## Custom scripts (Mods feature) From version 1.8.0, the Mods feature allows you to run an additional script when upgrading or installing an app. -Just put the script in question with the App ID followed by the `-preinstall`, `-install` or `-upgrade` suffix in the **mods** folder. +Just put the script in question with the **AppID** followed by the `-preinstall`, `-install` or `-upgrade` suffix in the **mods** folder. WAU will call `AppID-preinstall.ps1` before **winget** upgrades the app. WAU will call `AppID-install.ps1` and/or `AppID-upgrade.ps1` (if the install modes differs, otherwise the **-install** mod will be used for upgrades too) if it exists in the **mods** folder just after the upgrade/install. @@ -147,7 +147,7 @@ WAU will call `AppID-install.ps1` and/or `AppID-upgrade.ps1` (if the install mod If you want to run a script that removes the shortcut from **%PUBLIC%\Desktop** (we don't want to fill the desktop with shortcuts our users can't delete) just after installing **Acrobat Reader DC** (32-bit), prepare a powershell script that removes the Public Desktop shortcut **Acrobat Reader DC.lnk** and name your script like this: `Adobe.Acrobat.Reader.32-bit-install.ps1` and put it in the **mods** folder. -You can find more information on Winget-Install Repo, as it's a related feature +You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-Install#custom-mods), as it's a related feature ## Help In some cases, you need to "unblock" the `install.bat` file (Windows Defender SmartScreen). Right click, properties and unblock. Then, you'll be able to run it. From 7bdf0f3cb5ed5b9da26b3888190bb21e257f3f5b Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Tue, 29 Nov 2022 05:40:04 +0100 Subject: [PATCH 31/36] Text --- Winget-AutoUpdate/mods/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/mods/README.md b/Winget-AutoUpdate/mods/README.md index a779ec2..f73bc5d 100644 --- a/Winget-AutoUpdate/mods/README.md +++ b/Winget-AutoUpdate/mods/README.md @@ -1 +1 @@ -Post install custom scripts will be placed here +Pre/Post install custom scripts should be placed here From 9e2573eaea6d2c5f60ab4d6ea3ca2a2a2b27e766 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sun, 4 Dec 2022 01:55:40 +0100 Subject: [PATCH 32/36] $ModsInstall/$ModsInstalled --- Winget-AutoUpdate/functions/Test-Mods.ps1 | 8 ++++++-- Winget-AutoUpdate/functions/Update-App.ps1 | 23 +++++++++++----------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Winget-AutoUpdate/functions/Test-Mods.ps1 b/Winget-AutoUpdate/functions/Test-Mods.ps1 index e9177a1..1496ea2 100644 --- a/Winget-AutoUpdate/functions/Test-Mods.ps1 +++ b/Winget-AutoUpdate/functions/Test-Mods.ps1 @@ -4,8 +4,9 @@ function Test-Mods ($app) { #Takes care of a null situation $ModsPreInstall = $null - $ModsInstall = $null $ModsUpgrade = $null + $ModsInstall = $null + $ModsInstalled = $null $Mods = "$WorkingDir\mods" if (Test-Path "$Mods\$app-*") { @@ -19,8 +20,11 @@ function Test-Mods ($app) { if (Test-Path "$Mods\$app-upgrade.ps1") { $ModsUpgrade = "$Mods\$app-upgrade.ps1" } + if (Test-Path "$Mods\$app-installed.ps1") { + $ModsInstalled = "$Mods\$app-installed.ps1" + } } - return $ModsPreInstall, $ModsInstall, $ModsUpgrade + return $ModsPreInstall, $ModsUpgrade, $ModsInstall, $ModsInstalled } diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index 4a0d7f1..aedbc5a 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -17,7 +17,7 @@ Function Update-App ($app) { Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Balise $Balise -Button1Action $ReleaseNoteURL -Button1Text $Button1Text #Check if mods exist for preinstall/install/upgrade - $ModsPreInstall, $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) + $ModsPreInstall, $ModsUpgrade, $ModsInstall, $ModsInstalled = Test-Mods $($app.Id) #If PreInstall script exist if ($ModsPreInstall) { @@ -32,8 +32,10 @@ Function Update-App ($app) { Write-Log "-> Running: Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" & $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append - #Set mods to apply as an upgrade - $ModsMode = "Upgrade" + if ($ModsUpgrade) { + Write-Log "Modifications for $($app.Id) during upgrade are being applied..." "Yellow" + & "$ModsUpgrade" + } #Check if application updated properly $CheckOutdated = Get-WingetOutdatedApps @@ -55,8 +57,10 @@ Function Update-App ($app) { Write-Log "-> Running: Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append - #Set mods to apply as an install - $ModsMode = "Install" + if ($ModsInstall) { + Write-Log "Modifications for $($app.Id) during install are being applied..." "Yellow" + & "$ModsInstall" + } #Check if application installed properly $CheckOutdated2 = Get-WingetOutdatedApps @@ -69,13 +73,8 @@ Function Update-App ($app) { } if ($FailedToUpgrade -eq $false) { - - if (($ModsUpgrade) -and ($ModsMode -eq "Upgrade")) { - Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow" - & "$ModsUpgrade" - } - elseif (($ModsInstall) -and ($ModsMode -eq "Install")) { - Write-Log "Modifications for $($app.Id) after install are being applied..." "Yellow" + if ($ModsInstalled) { + Write-Log "Modifications for $($app.Id) after upgrade/install are being applied..." "Yellow" & "$ModsInstall" } } From 5703823d6a99f761aa86bbe925b5724b1749bfa9 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sun, 4 Dec 2022 02:30:28 +0100 Subject: [PATCH 33/36] $ModsInstalled now corrected! --- Winget-AutoUpdate/functions/Update-App.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index aedbc5a..b316b94 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -75,7 +75,7 @@ Function Update-App ($app) { if ($FailedToUpgrade -eq $false) { if ($ModsInstalled) { Write-Log "Modifications for $($app.Id) after upgrade/install are being applied..." "Yellow" - & "$ModsInstall" + & "$ModsInstalled" } } From 69ad8a674e7db60c2349c4965a2c91ca038c950e Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sun, 4 Dec 2022 03:51:07 +0100 Subject: [PATCH 34/36] README --- README.md | 5 +++-- Winget-AutoUpdate/mods/README.md | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2d30d8f..3f21121 100644 --- a/README.md +++ b/README.md @@ -139,9 +139,10 @@ See https://github.com/Romanitho/Winget-AutoUpdate/discussions/88 ## Custom scripts (Mods feature) From version 1.8.0, the Mods feature allows you to run an additional script when upgrading or installing an app. -Just put the script in question with the **AppID** followed by the `-preinstall`, `-install` or `-upgrade` suffix in the **mods** folder. +Just put the script in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. WAU will call `AppID-preinstall.ps1` before **winget** upgrades the app. -WAU will call `AppID-install.ps1` and/or `AppID-upgrade.ps1` (if the install modes differs, otherwise the **-install** mod will be used for upgrades too) if it exists in the **mods** folder just after the upgrade/install. +WAU will call `AppID-upgrade.ps1` and `AppID-install.ps1` (the **-install** mod will be used for upgrades too if **-upgrade** doesn't exist) if it exists in the **mods** folder during (just after the **winget** upgrade/install). +WAU will call `AppID-installed.ps1` after the upgrade/installation has been confirmed. > Example: If you want to run a script that removes the shortcut from **%PUBLIC%\Desktop** (we don't want to fill the desktop with shortcuts our users can't delete) just after installing **Acrobat Reader DC** (32-bit), prepare a powershell script that removes the Public Desktop shortcut **Acrobat Reader DC.lnk** and name your script like this: diff --git a/Winget-AutoUpdate/mods/README.md b/Winget-AutoUpdate/mods/README.md index f73bc5d..4242b09 100644 --- a/Winget-AutoUpdate/mods/README.md +++ b/Winget-AutoUpdate/mods/README.md @@ -1 +1 @@ -Pre/Post install custom scripts should be placed here +Pre/During/Post install custom scripts should be placed here From 90bdec9ca84aeeea9746ab3e26d5e7757fa3e26e Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sun, 4 Dec 2022 04:05:16 +0100 Subject: [PATCH 35/36] Text --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3f21121..2e48812 100644 --- a/README.md +++ b/README.md @@ -140,13 +140,15 @@ See https://github.com/Romanitho/Winget-AutoUpdate/discussions/88 ## Custom scripts (Mods feature) From version 1.8.0, the Mods feature allows you to run an additional script when upgrading or installing an app. Just put the script in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. -WAU will call `AppID-preinstall.ps1` before **winget** upgrades the app. -WAU will call `AppID-upgrade.ps1` and `AppID-install.ps1` (the **-install** mod will be used for upgrades too if **-upgrade** doesn't exist) if it exists in the **mods** folder during (just after the **winget** upgrade/install). -WAU will call `AppID-installed.ps1` after the upgrade/installation has been confirmed. +> Runs before upgrade/install: `AppID-preinstall.ps1` +> Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1` +> Runs after upgrade/install has been confirmed: `AppID-installed.ps1` -> Example: +The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist + +> Example: If you want to run a script that removes the shortcut from **%PUBLIC%\Desktop** (we don't want to fill the desktop with shortcuts our users can't delete) just after installing **Acrobat Reader DC** (32-bit), prepare a powershell script that removes the Public Desktop shortcut **Acrobat Reader DC.lnk** and name your script like this: -`Adobe.Acrobat.Reader.32-bit-install.ps1` and put it in the **mods** folder. +`Adobe.Acrobat.Reader.32-bit-installed.ps1` and put it in the **mods** folder. You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-Install#custom-mods), as it's a related feature From 6756e5774cd297f45cec6e9bba6531b96a46d9dd Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sun, 4 Dec 2022 04:08:02 +0100 Subject: [PATCH 36/36] Last text... --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2e48812..c38cff3 100644 --- a/README.md +++ b/README.md @@ -138,8 +138,8 @@ Remove scheduled tasks and scripts. See https://github.com/Romanitho/Winget-AutoUpdate/discussions/88 ## Custom scripts (Mods feature) -From version 1.8.0, the Mods feature allows you to run an additional script when upgrading or installing an app. -Just put the script in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. +From version 1.8.0, the Mods feature allows you to run additional scripts when upgrading or installing an app. +Just put the scripts in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install` or `-installed` suffix in the **mods** folder. > Runs before upgrade/install: `AppID-preinstall.ps1` > Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1` > Runs after upgrade/install has been confirmed: `AppID-installed.ps1`