How to Use Windows Package Manager to Streamline and Automate Application Installation

0


Using a package manager to install software is something that Linux users will be familiar with, but it’s not something that has been an option for anyone who uses Windows. But now that has changed since Microsoft released a preview of its Windows Package Manager utility.

You can consider using the winget command as an alternative to using the Microsoft Store to install the app or to using traditional executable installers. But it’s not fair and alternative – it also has the potential to be more flexible and powerful. Here’s how to use Windows Package Manager and how to script it to automate the installation of multiple programs.

See also:

First, you’ll need to get your hands on the Windows Package Manager, and there are a few different ways to do it. If you are a Windows Insider, you will already have the tool at your disposal, but there is also a dedicated Windows Package Manager Insider program. Alternatively, you can download it directly from GitHub.

Once you have access to the tool, you can use it through Windows Terminal, PowerShell, or Command Prompt, depending on your preference. We will be using PowerShell.

The first thing you can do is check what software is available for you to install. Use the following command:

winget install

You will be presented with an organized list of available software. Browse and write down the name of something you want to install. We will install the CPU-Z utility using the following command:

winget install cpu-z

After pressing Enter, the software is downloaded and installed, and you will then find it in the Start menu as usual.

You might be wondering what’s so special about this. It is, in the end, just another way of grasping software. But the Windows Package Manager becomes especially powerful if you use scripts. It might be easier using the command prompt because you can use Notepad to create a .BAT file to run your script.

In the example script below, we can use winget to install 7Zip, KeePass and Notepad ++:

@echo off

Echo Install 7Zip, KeePass and Notepad++

REM 7Zip

winget install 7Zip

if %ERRORLEVEL% EQU 0 Echo 7Zip installed successfully.

REM KeePass

winget install KeePass

if %ERRORLEVEL% EQU 0 Echo KeePass installed successfully.

REM Notepad++

winget install Notepad++

if %ERRORLEVEL% EQU 0 Echo Notepad++ installed successfully.   %ERRORLEVEL%

Of course, you can modify the script to install multiple or different programs, and it’s a great way to speed up the installation of common software on multiple computers or after reinstalling Windows.

If you prefer to use scripts in PowerShell, use the following format in a .ps1 file (in this example, we are installing Python and Discord):

winget install --id=Python.Python -e && winget install --id=Discord.Discord -e

You can also generate scripts using the Winstall site.


Share.

Comments are closed.