winget

2022-08-24

If you didn’t know already, Windows has a native command line package manager called winget.

Linux users will likely not find this as exciting news, since they’ve had tools like rpm, apt-get, and so on. Also, some Windows users may be saying “We’ve been having it”, with tools like Chocolatey. But for one to be built in with Windows and supported by Microsoft going forward is quite important I believe regarding adoption of the tooling.

For those that aren’t sure what a package manager is, well, winget can be used to automatically install some of the apps you would manually install in the past.

For example if you would like to install the Sysinternals Suite, you can run the below from a command line:

winget install sysinternals --accept-package-agreements

The above will also accept the end user license agreements, instead of prompting the user to do so.

The sysinternals argument above is actually a general query, so it’s likely better to make use of a specific package id to avoid any abuse by malicious package authors. Or maybe I’m just paranoid, but an example when installing 7zip with the id is below:

winget install --id 7zip.7zip

Sometimes these ids can be a bit strange, for example the id for sysinternals is 9P7KNL5RWT25 which seems a bit random and made me wonder if its a legit package:

C:\>winget search sysinternals
Name               Id                                     Version Source
--------------------------------------------------------------------------
Sysinternals Suite 9P7KNL5RWT25                           Unknown msstore
Process Monitor    Microsoft.Sysinternals.ProcessMonitor  3.91    winget
Autoruns           Microsoft.Sysinternals.Autoruns        14.09   winget
Process Explorer   Microsoft.Sysinternals.ProcessExplorer 16.43   winget

You can also list what’s currently installed:

winget list

Or if you want to check details of a specific package you can also provide its id (notice how its not case sensitive):

C:\>winget list --id notepad++.notepad++
Name                   Id                  Version Available Source
-------------------------------------------------------------------
Notepad++ (64-bit x64) Notepad++.Notepad++ 8.4.3   8.4.4     winget

In the example above, we can see there’s a newer version of Notepad++ to the one that’s installed. You can also show more details about a specific package:

C:\>winget show --id notepad++.notepad++
Found Notepad++ [Notepad++.Notepad++]
Version: 8.4.4
Publisher: Notepad++ Team
Publisher Url: https://notepad-plus-plus.org
Publisher Support Url: https://notepad-plus-plus.org/online-help
Author: Don Ho
Moniker: notepad++
Description: Notepad++ is a free (as in “free speech” and also as in “free beer”) source code editor and Notepad replacement that supports several languages. Running in the MS Windows environment, its use is governed by GNU General Public License.
Homepage: https://notepad-plus-plus.org
License: GPL-3.0-or-later
License Url: https://raw.githubusercontent.com/notepad-plus-plus/notepad-plus-plus/master/LICENSE
Copyright: Copyright (C)2021 Don HO <don.h@free.fr>.
Copyright Url: https://raw.githubusercontent.com/notepad-plus-plus/notepad-plus-plus/master/LICENSE
Installer:
  Type: nullsoft
  Download Url: https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.4.4/npp.8.4.4.Installer.x64.exe
  SHA256: 638bd860149703820bf605e1098d9fa158982281cc7cfda788416c1fd3093931

And also show the available versions:

C:\>winget show --id notepad++.notepad++ --versions
Found Notepad++ [Notepad++.Notepad++]
Version
-------
8.4.4
8.4.3
8.4.2
8.4.1
8.4
8.3.3
8.3.1
8.2.1
8.2
8.1.9.3
8.1.9.2
8.1.5
8.1.4
8.1.3
8.1.2
8.1.1
8.1
8.0
7.9.5
7.9.4
7.9.3
7.9.2
7.9.1
7.9
7.8.9
7.8.8
7.8.7
7.8.6

In this case you can then just run the upgrade command:

winget upgrade notepad++

Finally, there’s also a website where you can go to find more information on packages, for those that do like a bit of a GUI:

https://winget.run/pkg/Notepad++/Notepad++

I really enjoy this winget App Installer experience, although I still sometimes feel like I’d have more control over how my applications are installed, what options are set, which location its installed to.

Maybe I am just too used to the way I used to do things, and should just get used to this more modern, easier way.

Of course, in future, it may just be that I need to set specific command line switches or update configuration files to get it to my liking. I only see this as a positive for the future of Windows.

Especially for example working as a software developer in a team, being able to automate the installation of an environment is crucial for repeatability and consistent experiences.

References