Recently, a colleague told me about the new winget feature in Windows 10. This command line based package manager is developed by Microsoft as open source (CLI and repository) and offers the same features as, for example, apt-get in Ubuntu: software can be installed, updated and removed via command line.
Developers of applications can register their software in the “Windows Package Manager Community Repository” from where other developers can install them as “packages” using the CLI. Microsoft scans every package for malware which offers a basic security protection.
Benefits of a Package Manager
Of course, applications can be installed by downloading the installer and manually executing it. However, with a package manager, all applications are downloaded from one trusted source. That eliminates the danger of googling a malicious website and downloading malware instead of the intended tool. Also, this is the reason only trusted sources should be added to a package manager.
Another benefit of a package manager is that it can be used easily in scripts. For example, a software development team could assemble a list of applications usually used in the team to allow a quick onboarding of new team members. They only have to execute the script to set up their working environment. Yes, this could also be done with downloads from the tool’s websites. However, winget also supports downloading such lists. Doing this with winget is way easier than scripting everything by hand.
The last benefit I want to mention here is the centralized notification about updates. Yes, tools have their own ways to inform the user about new versions. However, having those in a central place is preferable and easier to manage.
Main Use Cases As Examples
Show current sources of packages:
Search a package in the sources:
Show installed packages:
Filter list of installed packages:
Show all installed packages with available upgrades:
Upgrade specific package:
Upgrade all packages:
Creating a Scheduled Task
Having all packages up to date is not only a good idea because of the potential new features of newer versions, it enhances security, too. With its task scheduler, Windows offers a way to run upgrades periodically like a batch job.
- Open the task scheduler with Windows key and search for “task scheduler”.
- Right-click on “Task Scheduler Library” and create a simple task.
- The program to start is C:\Users\your-user-id\AppData\Local\Microsoft\WindowsApps\winget.exe with the argument “upgrade –all”
Creating a Scheduled Task to Only Display Upgrades
Upgrading the packages automatically as shown above is the best way to stay up to date. However, if a package cannot be upgraded for some reason, the whole job stops and the packages after the canceled one will not be upgraded. There is an issue for this, but it’s still open for development.
On my working laptop, I don’t have the permissions to upgrade any Microsoft packages as they are managed by the admins in my company. Currently, winget cannot filter the packages to be updated, so I created a batch script to display all packages with upgrades. Using the Windows task scheduler, this script is my daily reminder to upgrade the applications manually.
Create a file named “winget-upgrade.bat” with the following content in some script- or tool folder:
The line beginning with “winget” executes winget to show the list of packages with upgrades available. Using “findstr”, this list is filtered so it includes nothing with “Microsoft” in it.
Instead of creating a scheduled task which calls the winget.exe with the argument “upgrade –all”, enter the path to the batch file and no argument instead.
This will show something like:
Here are some (German) YouTube videos for the topic:
- “Endlich: Microsoft WinGet ermöglicht automatische Software Updates und Installationen”
- “Auto Update mit Winget bei jedem PC Start (feat. Windows Aufgabenplaner)”