Skip to content

Commit

Permalink
fix: PatchMyPC conflict with winget update (#44)
Browse files Browse the repository at this point in the history
Make sure PatchMyPC is executed after winget finishes.
  • Loading branch information
scadu committed May 10, 2024
1 parent 661c84f commit 7aa8676
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/powershell/Update-System.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,26 @@ function Get-WslUpdate {

function Get-ProgramsUpdate {
Write-Output "Updating winget packages"
winget upgrade --all
# Using Start-Process to control the execution flow with -Wait
# to ensure PatchMyPC won't start until winget finishes
Start-Process -FilePath "winget" -ArgumentList "upgrade --all" -NoNewWindow -Wait

if (-not (Test-Path -Path $AppsDirectory)) {
New-Item $AppsDirectory -ItemType Directory | Out-Null
}

$PatchMyPCBinary = "https://patchmypc.com/freeupdater/PatchMyPC.exe"
if (-not(Test-Path $AppsDirectory\PatchMyPC.exe -PathType Leaf)) {
Write-Warning "PatchMyPC not found. Downloading..."
Invoke-WebRequest $PatchMyPCBinary -OutFile "$AppsDirectory\PatchMyPC.exe"
}

try {
Write-Output "Updating programs with PatchMyPC"
Start-Process -FilePath "$AppsDirectory\PatchMyPC.exe" -ArgumentList "/auto"
Start-Process -FilePath "$AppsDirectory\PatchMyPC.exe" -ArgumentList "/auto" -Wait
}
catch {
Write-Error "Error: $($_.Exception.Message)"
Write-Error "Error in PatchMyPC update: $($_.Exception.Message)"
}
}

Expand Down

0 comments on commit 7aa8676

Please sign in to comment.