Happy Saturday! Welcome back to another blog post. In this edition, we’ll be taking a short break from OneDrive to have a quick dive into managing applications using the command line tool winget - Microsoft’s “Client Interface to the Windows Package Manager service”.
If you’re looking for another way to install, update, and uninstall software on Windows, you’re in the right place. Let’s get started!
Checking if Winget is Installed
Winget is supported on Windows 10 1709 (build 16299) or later. Before we jump in, let’s make sure it’s installed in your environment. You can easily check by opening your command prompt or PowerShell and typing the following:
|
|
or
|
|
If Winget is installed, you’ll see a helpful command summary along with various options and commands that you can use.
An important note from Microsoft on this: The winget tool will not be available until you have logged into Windows as a user for the first time, triggering Microsoft Store to register Windows Package Manager as part of an asynchronous process. If you have recently logged in as a user for the first time and find that winget is not yet available, you can open PowerShell and enter the following command to request this winget registration: Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe
Installing the Latest Version of Winget
If you’re missing Winget or want to ensure you have the latest version, you can install it using the following command from Microsoft:
|
|
You could also install “App Installer” through the Microsoft Store to get to the same outcome.
Navigating Available Command Line Options
Winget offers an array of powerful command-line options that enable you to perform various tasks. To explore them in detail, you can use the following command:
|
|
This will provide you with a handy list of commands, Each with their own context relevant options:
To get more details on any specific commands available options, pass them the help argument. [-?]
for example, winget install -?
would return the relevant options realating to installation. Some of these that are going to be relevant to us shortly are:
Install Option | Description |
---|---|
–id | Filter results by id |
–name | Filter results by name |
-h,–silent | Request silent installation |
–accept-package-agreements | Accept all licenseagreements for packages |
–disable-interactivity | Disable interactive prompts |
Searching for Packages
Finding packages with Winget is simple. If you’re looking for, let’s say, Google Chrome, you can use the following command:
|
|
This will present you with a list of matching packages, along with their IDs, versions, and sources.
Getting Package Information
Curious about the details of a specific package? You can use the show
command to retrieve comprehensive information. For instance, to get details about Google Chrome, you can use:
|
|
It’s a good idea to use the ‘Show’ command to verify the package you are interacting with, is what you think it is.
Silently Installing a Package
Sometimes you might want to install packages without any prompts. To do so, use the --silent
flag. For example:
|
|
Silently Upgrading All Packages
To keep your applications up to date without manual intervention, use the upgrade
command with the following options:
|
|
Scripting winget
Microsoft provides an Example Bash script that can install packages one after another using Winget.
|
|
An important note from Microsoft on this: When scripted, winget will launch the applications in the specified order. When an installer returns success or failure, winget will launch the next installer. If an installer launches another process, it is possible that it will return to winget prematurely. This will cause winget to install the next installer before the previous installer has completed.
Silently Installing Multiple Specific Packages (One Liner)
If you want to automate the installation of a specific set of packages, you can use a script like this:
|
|
Listing Installed Packages
You can get a list of installed packages using the command:
|
|
This command will output a table of installed packages and properties such as Name, Id, Version
& Available Source
.
Interestingly, this command will even display packages that were not originally installed through Windows Package Manager.
Silently Uninstalling a Package
Removing packages silently is just as easy. For example, to silently uninstall Google Chrome:
|
|
With these Winget commands and techniques, you have the power to manage your applications using Microsofts own package manager.
That’s it for today! I hope this quick dive into managing applications with Winget proves helpful. Until next time, happy coding and exploring! 🚀