From ac47b9d78bd30469424d1e2476f1b30222065269 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 1 Nov 2023 19:28:25 +0100 Subject: [PATCH 1/3] Now returns success, fail or current from Update-WinGet --- Winget-AutoUpdate/functions/Update-WinGet.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Winget-AutoUpdate/functions/Update-WinGet.ps1 b/Winget-AutoUpdate/functions/Update-WinGet.ps1 index 9b32a6b..8aea0fe 100644 --- a/Winget-AutoUpdate/functions/Update-WinGet.ps1 +++ b/Winget-AutoUpdate/functions/Update-WinGet.ps1 @@ -69,11 +69,13 @@ Function Update-WinGet { $WingetCmd = $WingetInfo[-1].FileName & $WingetCmd source reset --force Write-ToLog "-> WinGet sources reset.`n" "green" + return "success" } catch { Write-ToLog "-> Failed to install WinGet MSIXBundle for App Installer...`n" "red" Update-StoreApps + return "fail" } #Remove WinGet MSIXBundle @@ -81,5 +83,6 @@ Function Update-WinGet { } else { Write-ToLog "-> WinGet is up to date: v$WinGetInstalledVersion`n" "Green" + return "current" } } From 1fdc28796027fc9f5e24f56fc2c10e7618f33cb9 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 1 Nov 2023 22:32:50 +0100 Subject: [PATCH 2/3] Remove WinGet Installer --- Winget-AutoUpdate/functions/Update-WinGet.ps1 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Winget-AutoUpdate/functions/Update-WinGet.ps1 b/Winget-AutoUpdate/functions/Update-WinGet.ps1 index 8aea0fe..975796e 100644 --- a/Winget-AutoUpdate/functions/Update-WinGet.ps1 +++ b/Winget-AutoUpdate/functions/Update-WinGet.ps1 @@ -62,6 +62,8 @@ Function Update-WinGet { Write-ToLog "-> Installing WinGet MSIXBundle for App Installer..." Add-AppxProvisionedPackage -Online -PackagePath $WingetInstaller -SkipLicense | Out-Null Write-ToLog "-> WinGet MSIXBundle (v$WinGetAvailableVersion) for App Installer installed successfully!" "green" + #Remove WinGet MSIXBundle + Remove-Item -Path $WingetInstaller -Force -ErrorAction SilentlyContinue #Reset WinGet Sources $WingetInfo = (Get-Item "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_8wekyb3d8bbwe\winget.exe").VersionInfo | Sort-Object -Property FileVersionRaw @@ -74,12 +76,12 @@ Function Update-WinGet { } catch { Write-ToLog "-> Failed to install WinGet MSIXBundle for App Installer...`n" "red" + #Remove WinGet MSIXBundle + Remove-Item -Path $WingetInstaller -Force -ErrorAction SilentlyContinue + #Force Store Apps to update Update-StoreApps return "fail" } - - #Remove WinGet MSIXBundle - Remove-Item -Path $WingetInstaller -Force -ErrorAction SilentlyContinue } else { Write-ToLog "-> WinGet is up to date: v$WinGetInstalledVersion`n" "Green" From 17d2c2d76af4cd68d2e9bc157ec4855a1d14b621 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 1 Nov 2023 22:50:44 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Return=20status=20=C3=A0=20la=20@Romanitho?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Winget-AutoUpdate/functions/Update-WinGet.ps1 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Winget-AutoUpdate/functions/Update-WinGet.ps1 b/Winget-AutoUpdate/functions/Update-WinGet.ps1 index 975796e..575d869 100644 --- a/Winget-AutoUpdate/functions/Update-WinGet.ps1 +++ b/Winget-AutoUpdate/functions/Update-WinGet.ps1 @@ -62,8 +62,6 @@ Function Update-WinGet { Write-ToLog "-> Installing WinGet MSIXBundle for App Installer..." Add-AppxProvisionedPackage -Online -PackagePath $WingetInstaller -SkipLicense | Out-Null Write-ToLog "-> WinGet MSIXBundle (v$WinGetAvailableVersion) for App Installer installed successfully!" "green" - #Remove WinGet MSIXBundle - Remove-Item -Path $WingetInstaller -Force -ErrorAction SilentlyContinue #Reset WinGet Sources $WingetInfo = (Get-Item "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_8wekyb3d8bbwe\winget.exe").VersionInfo | Sort-Object -Property FileVersionRaw @@ -71,17 +69,21 @@ Function Update-WinGet { $WingetCmd = $WingetInfo[-1].FileName & $WingetCmd source reset --force Write-ToLog "-> WinGet sources reset.`n" "green" - return "success" + $return = "success" } catch { Write-ToLog "-> Failed to install WinGet MSIXBundle for App Installer...`n" "red" - #Remove WinGet MSIXBundle - Remove-Item -Path $WingetInstaller -Force -ErrorAction SilentlyContinue #Force Store Apps to update Update-StoreApps - return "fail" + $return = "fail" } + + #Remove WinGet MSIXBundle + Remove-Item -Path $WingetInstaller -Force -ErrorAction SilentlyContinue + + #Return status + return $return } else { Write-ToLog "-> WinGet is up to date: v$WinGetInstalledVersion`n" "Green"