Microsoft's new package manager can install a variety of applications without user intervention. However, the tool only accepts the name of a single program on the command line. A batch file or the exported configuration of a reference system can be used to install multiple apps with winget.

If you have to set up new computers or virtual machines very often, then you will have to install the usual collection of free standard apps. Typical candidates are editors, packers, web browsers, and image editing tools.

If you do not have a central solution for software distribution, you can use the package manager winget as an alternative. It is included in Windows 11, and in Windows 10, you can add it via the App Installer from the Microsoft Store.

Winget is part of the app installer and can be downloaded from the Store or from GitHub

Winget is part of the app installer and can be downloaded from the Store or from GitHub

The package manager installs applications from Microsoft's community repository and, since the first official release, also from the Store. In principle, one can also include local repos, but this option is not a ready-to-use product.

Only one program per command ^

The basic procedure for adding software is to search the repositories for a specific package and then provide winget with the name or ID of the software in another command. Repeat this for each individual program.

If you want to install all the packages you need on multiple machines, this procedure will be too cumbersome.

Identifying commands for the installation ^

Therefore, it is advisable to combine all the necessary commands in a batch file. To do this, you must first determine the exact name or ID:

winget search <Name of the App>

Here, you can immediately check which package you would like to choose from the relatively chaotic offer. This is then installed with

winget install <ID or Name>

If there are several versions of a program, you can specify a particular one with the -v parameter.

Installing Notepad using winget

Installing Notepad using winget

Unsuccessful search for Sysinternals ^

If a program comes from the Store but winget cannot find it, it may still be possible to install it if you take the ID from the Store URL. An example of this is Sysinternals, where the use of

winget search sysinternals

does not result in a hit. The command

winget install 9p7knl5rwt25 --accept-package-agreements

brings about a successful installation. The --accept-package-agreements switch suppresses the interactive confirmation of the license conditions.

The Sysinternals Suite cannot currently be found using winget and can only be installed via the I

The Sysinternals Suite cannot currently be found using winget and can only be installed via the I

Install multiple apps ^

Once you have added all the desired programs, you can collect the individual commands and compile them in a batch file. If the installation is successful, winget will generate a return value of 0; this can be used to display a corresponding message or to trigger another action.

In PowerShell, it could look like this:

winget install notepad++
if($LASTEXITCODE){"Notepad++ successfully installed!"}

Export reference installation ^

If you already have some of the required programs installed on a machine, you can export this list to a JSON file:

winget export -o .\winget-export.json

The packages do not even have to be added using winget. The package manager will look up the names of all installed apps in the repository and add them to the list. If they do not exist in the repo, winget will issue a corresponding message.

Winget indicates when installed programs do not exist in the repository

Winget indicates when installed programs do not exist in the repository

However, the disadvantage of this method is that all store apps preinstalled in Windows will also show up in the JSON file. Therefore, you will have to clean it up in an editor before use.

Cleaned version of the exported program list

Cleaned version of the exported program list

If the export file is in the desired state, you can transfer it to another computer and pass it to the import command there:

winget import -i .\winget-export.json --accept-package-agreements

Now the installation of all programs should run smoothly.

Automatic installation of all programs specified in the JSON file

Automatic installation of all programs specified in the JSON file

If you start the command prompt or PowerShell without administrative rights, you will be confronted with the UAC dialog for most of the Win32 programs.

Conclusion ^

With the new package manager winget, multiple common standard apps can be installed in one go, largely without user intervention. To do this, however, you must first compile all the necessary commands and transfer them to a script.

Subscribe to 4sysops newsletter!

If you already have a computer with all the desired programs, you can export this list from there, clean out unnecessary apps, and then transfer it to other PCs as an import configuration.

avatar
4 Comments
  1. Will 5 months ago

    This is nice and all. But for businesses it doesn’t work. This has to have connection to the store which is also being deprecated. I don’t understand what Microsoft is thinking with their apps, or products when they do things like build a store that will undo itself.

  2. Phillip Nguyen 2 months ago

    Thank you for sharing.
    For some reason the switch “–accept-package-agreements” didn’t work for my case.
    Below is the output at the end.

    Do you agree to all the source agreements terms?
    [Y] Yes [N] No: An unexpected error occurred while executing the command:
    0x8a150042 : Error reading input in prompt

    The command I ran is “winget install wingetcreate –accept-package-agreements”

    • Surender Kumar 2 weeks ago

      Please try the following command:

      winget install wingetcreate --accept-source-agreements

  3. Surender Kumar 2 weeks ago

    Thank you for the useful post. If anyone want to silently upgrade all the apps using winget, use the following command:

    winget upgrade --all --silent --accept-source-agreements --accept-package-agreements 

    P.S. – It requires Windows 10 1809 (build 17763) or later.

Leave a reply

Your email address will not be published.

*

© 4sysops 2006 - 2022

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account