From 82598adf05365fb3e338134966bad56fe5a9c1fc Mon Sep 17 00:00:00 2001 From: romanitho <96626929+Romanitho@users.noreply.github.com> Date: Wed, 29 Jun 2022 17:32:03 +0200 Subject: [PATCH 1/3] add metered connection detection and option --- Winget-AutoUpdate-Install.ps1 | 6 ++++ Winget-AutoUpdate/functions/Test-Network.ps1 | 29 +++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 1ba6744..468f37c 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -34,6 +34,9 @@ Set WAU to run at user logon. .PARAMETER UpdatesInterval Specify the update frequency: Daily (Default), Weekly, Biweekly or Monthly. +.PARAMETER RunOnMetered +Run WAU on metered connection. Default No. + .EXAMPLE .\winget-install-and-update.ps1 -Silent -DoNotUpdate @@ -251,6 +254,9 @@ function Install-WingetAutoUpdate { if ($UseWhiteList) { New-ItemProperty $regPath -Name WAU_UseWhiteList -Value 1 -PropertyType DWord -Force | Out-Null } + if (!$RunOnMetered) { + New-ItemProperty $regPath -Name WAU_DoNotRunOnMetered -Value 1 -PropertyType DWord -Force | Out-Null + } Write-host "WAU Installation succeeded!" -ForegroundColor Green Start-sleep 1 diff --git a/Winget-AutoUpdate/functions/Test-Network.ps1 b/Winget-AutoUpdate/functions/Test-Network.ps1 index 9e5c332..0e331e5 100644 --- a/Winget-AutoUpdate/functions/Test-Network.ps1 +++ b/Winget-AutoUpdate/functions/Test-Network.ps1 @@ -14,7 +14,34 @@ function Test-Network { if ($TestNetwork) { Write-Log "Connected !" "Green" - return $true + + #Check for metered connection + [void][Windows.Networking.Connectivity.NetworkInformation, Windows, ContentType = WindowsRuntime] + $cost = [Windows.Networking.Connectivity.NetworkInformation]::GetInternetConnectionProfile().GetConnectionCost() + + if ($cost.ApproachingDataLimit -or $cost.OverDataLimit -or $cost.Roaming -or $cost.BackgroundDataUsageRestricted -or ($cost.NetworkCostType -ne "Unrestricted")){ + + Write-Log "Metered connection detected." "Yellow" + + if ($WAUConfig.WAU_DoNotRunOnMetered -eq 1) { + + Write-Log "WAU is configured to bypass update checking on metered connection" + return $false + + } + else{ + + Write-Log "WAU is configured to force update checking on metered connection" + return $true + + } + + } + else{ + + return $true + + } } else { From 9c5e2cbe0de7e7a6f7f0c43ae4a04c5da9d14086 Mon Sep 17 00:00:00 2001 From: romanitho <96626929+Romanitho@users.noreply.github.com> Date: Wed, 29 Jun 2022 17:33:57 +0200 Subject: [PATCH 2/3] v1.12.0 --- Winget-AutoUpdate-Install.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 468f37c..4463719 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -63,7 +63,7 @@ param( <# APP INFO #> -$WAUVersion = "1.11.5" +$WAUVersion = "1.12.0" <# FUNCTIONS #> From 13ac2c2eb4eb29806b2075766a288c45e7bca371 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sat, 2 Jul 2022 08:49:44 +0200 Subject: [PATCH 3/3] v1.12.0 --- README.md | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index cb916ac..eb3bb8f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This project uses the Winget tool to daily update apps (with system context) and ![image](https://user-images.githubusercontent.com/96626929/150645599-9460def4-0818-4fe9-819c-dd7081ff8447.png) ## Intallation -Just [download latest version](https://github.com/Romanitho/Winget-AutoUpdate/archive/refs/tags/v1.11.4.zip), unzip, run "install.bat" as admin to install by default. +Just [download latest version](https://github.com/Romanitho/Winget-AutoUpdate/archive/refs/tags/v1.12.0.zip), unzip, run "install.bat" as admin to install by default. ## Configurations ### Keep some apps out of Winget-AutoUpdate @@ -43,13 +43,21 @@ As explained in this [post](https://github.com/microsoft/winget-cli/issues/1255) Eventually, try to reinstall or update app manually to see if new version is detected. +### Handle metered connections + +We might want to stop WAU on metered connection (to save cellular data on connection sharing for instance). That's why from v1.12.0 the default behavior will detect and stop WAU on limited connections (only for fresh install). + +> Previous installed versions will ignore this new setting on update to keep historical operation. + +To force WAU to run on metered connections anyway, run new installation with `-RunOnMetered` parameter. + ## Update WAU ### Manual Update -Same process as new installation : download, unzip and run "install.bat". +Same process as new installation : download, unzip and run `install.bat`. ### Automatic Update A new Auto-Update process has been released from version 1.5.0. By default, WAU AutoUpdate is enabled. It will not overwrite the configurations, icons (if personalised), excluded_apps list,... -To disable WAU AutoUpdate, run the "winget-install-and-update.ps1" with "-DisableWAUAutoUpdate" parameter +To disable WAU AutoUpdate, run the `winget-install-and-update.ps1` with `-DisableWAUAutoUpdate` parameter ## Uninstall WAU Simply uninstall it from your programs: @@ -89,6 +97,8 @@ Set WAU to run at user logon. **-UpdatesInterval** Specify the update frequency: Daily (Default), Weekly, Biweekly or Monthly. +**-RunOnMetered** +Run WAU on metered connection. Default No. **-Uninstall** Remove scheduled tasks and scripts. @@ -98,7 +108,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 "-upgrade" or "-install" suffix in the "mods" folder. +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. > Example: @@ -108,7 +118,7 @@ If you want to run a script that removes the shortcut from "%PUBLIC%\Desktop" (w You can find more information on Winget-Install Repo, 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. +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. ## Optimization -Feel free to give us any suggestions or optimizations in code. +Feel free to give us any suggestions or optimizations in code and support us by adding a star :)