Skip to main content

Upgrading a package with winget

What

Wingetwinget is a command line tool to manage applications on the Windows 10 and 11 platform.

When/Why

Of course, installing a package is only the beginning.  After we initially install any package, we'll have to come back from time to time to update that application for security and feature updates.

Similarly to other platforms where installs are coming directly from a CDN source, any software installed in this method will bypass FileWave boosters since the content is coming straight from the internet.

How

Our process for updating a package is very similar to our installation code, and equally simple.  We'll use the winget "upgrade" command to update a previously installed package.  You'll find Microsoft documentation on the upgrade command here.  And the upgrade command is shown in action in the last line below:

# Get the path to winget.exe
$winget = (Get-ChildItem -Path "C:\Program Files\WindowsApps\" -Filter "winget.exe" -Recurse | Sort-Object -Property LastWriteTime | Select-Object -Last 1).FullName

# Get the directory that winget.exe is inside of
$wingetdir = Split-Path -Path $winget -Parent

# we change directory to this locale so we can run the winget command without the full path
cd $wingetdir

# adding the authorization acceptance here is superfluous if it has already been accepted, but it won't harm anything to include
.\winget.exe upgrade --exact --id Mozilla.Firefox --accept-package-agreements --accept-source-agreements

Utilization of the --version option may be very helpful as well since it lets you control upgrading to a specific version.