Merge pull request #218 from Romanitho/main

merged last changes
pull/214/head
Romain 2022-10-26 14:17:23 +02:00 committed by GitHub
commit f28ffed5cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 23 deletions

View File

@ -88,6 +88,9 @@ Use White List instead of Black List. This setting will not create the "excluded
**-ListPath** **-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) (copy/download to Winget-AutoUpdate installation location if external list is newer).
**-InstallUserContext**
Install WAU with system and **user** context executions (From version 1.15.3)
**-BypassListForUsers** **-BypassListForUsers**
Bypass Black/White list when run in user context (From version 1.15.0) Bypass Black/White list when run in user context (From version 1.15.0)

View File

@ -3,7 +3,9 @@
Function Get-WingetCmd { Function Get-WingetCmd {
#Get WinGet Path (if admin context) #Get WinGet Path (if admin context)
$ResolveWingetPath = Resolve-Path "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe" | Sort-Object { [version]($_.Path -replace '^[^\d]+_((\d+\.)*\d+)_.*', '$1') } # Includes Workaround for ARM64 (removed X64 and replaces it with a wildcard)
$ResolveWingetPath = Resolve-Path "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_*__8wekyb3d8bbwe" | Sort-Object { [version]($_.Path -replace '^[^\d]+_((\d+\.)*\d+)_.*', '$1') }
if ($ResolveWingetPath) { if ($ResolveWingetPath) {
#If multiple version, pick last one #If multiple version, pick last one
$WingetPath = $ResolveWingetPath[-1].Path $WingetPath = $ResolveWingetPath[-1].Path
@ -29,7 +31,7 @@ Function Get-WingetCmd {
#Log Winget installed version #Log Winget installed version
$WingetVer = & $Winget --version $WingetVer = & $Winget --version
Write-Log "Winget Version: $WingetVer" Write-Log "Winget Version: $WingetVer"
return $true return $true
} }

View File

@ -1,55 +1,58 @@
#Function to check connectivity #Function to check connectivity
function Test-Network { function Test-Network {
#Init #Init
$timeout = 0 $timeout = 0
# Workaround for ARM64 (Access Denied / Win32 internal Server error)
$ProgressPreference = 'SilentlyContinue'
#Test connectivity during 30 min then timeout #Test connectivity during 30 min then timeout
Write-Log "Checking internet connection..." "Yellow" Write-Log "Checking internet connection..." "Yellow"
While ($timeout -lt 1800) { While ($timeout -lt 1800) {
$URLtoTest = "https://raw.githubusercontent.com/Romanitho/Winget-AutoUpdate/main/LICENSE" $URLtoTest = "https://raw.githubusercontent.com/Romanitho/Winget-AutoUpdate/main/LICENSE"
$URLcontent = ((Invoke-WebRequest -URI $URLtoTest -UseBasicParsing).content) $URLcontent = ((Invoke-WebRequest -URI $URLtoTest -UseBasicParsing).content)
if ($URLcontent -like "*MIT License*") { if ($URLcontent -like "*MIT License*") {
Write-Log "Connected !" "Green" Write-Log "Connected !" "Green"
#Check for metered connection #Check for metered connection
[void][Windows.Networking.Connectivity.NetworkInformation, Windows, ContentType = WindowsRuntime] [void][Windows.Networking.Connectivity.NetworkInformation, Windows, ContentType = WindowsRuntime]
$cost = [Windows.Networking.Connectivity.NetworkInformation]::GetInternetConnectionProfile().GetConnectionCost() $cost = [Windows.Networking.Connectivity.NetworkInformation]::GetInternetConnectionProfile().GetConnectionCost()
if ($cost.ApproachingDataLimit -or $cost.OverDataLimit -or $cost.Roaming -or $cost.BackgroundDataUsageRestricted -or ($cost.NetworkCostType -ne "Unrestricted")) { if ($cost.ApproachingDataLimit -or $cost.OverDataLimit -or $cost.Roaming -or $cost.BackgroundDataUsageRestricted -or ($cost.NetworkCostType -ne "Unrestricted")) {
Write-Log "Metered connection detected." "Yellow" Write-Log "Metered connection detected." "Yellow"
if ($WAUConfig.WAU_DoNotRunOnMetered -eq 1) { if ($WAUConfig.WAU_DoNotRunOnMetered -eq 1) {
Write-Log "WAU is configured to bypass update checking on metered connection" Write-Log "WAU is configured to bypass update checking on metered connection"
return $false return $false
} }
else { else {
Write-Log "WAU is configured to force update checking on metered connection" Write-Log "WAU is configured to force update checking on metered connection"
return $true return $true
} }
} }
else { else {
return $true return $true
} }
} }
else { else {
Start-Sleep 10 Start-Sleep 10
$timeout += 10 $timeout += 10
#Send Warning Notif if no connection for 5 min #Send Warning Notif if no connection for 5 min
if ($timeout -eq 300) { if ($timeout -eq 300) {
Write-Log "Notify 'No connection' sent." "Yellow" Write-Log "Notify 'No connection' sent." "Yellow"
@ -59,11 +62,11 @@ function Test-Network {
$Balise = "connection" $Balise = "connection"
Start-NotifTask $Title $Message $MessageType $Balise Start-NotifTask $Title $Message $MessageType $Balise
} }
} }
} }
#Send Timeout Notif if no connection for 30 min #Send Timeout Notif if no connection for 30 min
Write-Log "Timeout. No internet connection !" "Red" Write-Log "Timeout. No internet connection !" "Red"
$Title = $NotifLocale.local.outputs.output[1].title $Title = $NotifLocale.local.outputs.output[1].title

View File

@ -32,23 +32,23 @@
</output> </output>
<output id="5"> <output id="5">
<!--Logs are not available yet--> <!--Logs are not available yet-->
<message>Logs are not available yet!</message> <message>Die Logs sind aktuell nicht verfügbar!</message>
</output> </output>
<output id="6"> <output id="6">
<!--Starting a manual check for updated apps--> <!--Starting a manual check for updated apps-->
<message>Starting a manual check for updated apps...</message> <message>Starte die manuelle Suche nach Updates.</message>
</output> </output>
<output id="7"> <output id="7">
<!--Couldn't start a manual check for updated apps--> <!--Couldn't start a manual check for updated apps-->
<message>Couldn't start a manual check for updated apps!</message> <message>Die manuelle Suche nach Updates konnte nicht gestartet werden!</message>
</output> </output>
<output id="8"> <output id="8">
<!--Check for updated apps already running--> <!--Check for updated apps already running-->
<message>Check for updated apps already running...</message> <message>Die Such nach Updates läuft bereits.</message>
</output> </output>
<output id="9"> <output id="9">
<!--Manual check for updated apps completed--> <!--Manual check for updated apps completed-->
<message>Manual check for updated apps completed...</message> <message>Die manuelle suche nach Updates wurde abgeschlossen.</message>
</output> </output>
</outputs> </outputs>
</local> </local>