- Recommended security settings and new group policies for Microsoft Edge (from 107 on) - Fri, Jan 27 2023
- Save and access the BitLocker recovery key in the Microsoft account - Tue, Jan 24 2023
- Reopen apps after Windows startup - Thu, Jan 19 2023
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.
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.
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.
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.
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.
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.
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.
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.
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”
Please try the following command:
Thank you for the useful post. If anyone want to silently upgrade all the apps using winget, use the following command:
P.S. – It requires Windows 10 1809 (build 17763) or later.