banner
CG艺术实验室

CG艺术实验室

数字艺术 / 视觉设计 / 技术分享 / 知识管理
tg_channel
facebook
x
github
bilibili
zhihu
email

Windows Software Store Replacement - Winget

Introduction#

After ten years of graduation, I have been using computers to write, draw, design, and create videos. I have always resisted coding until I have reinstalled the system countless times, and each time I have to reinstall software for an entire afternoon. I even have a software installation package folder specifically in my NAS. Could my ultimate destiny be coding?

What is winget#

winget is a software management tool launched by Microsoft that runs in the Windows terminal. It is only supported in Windows 10 version 1709 and higher, and the core command is winget. When you enter winget in the terminal, you will see:

PS C:\Users\cgart> winget
Windows Package Manager v1.7.10582
Copyright (C) Microsoft Corporation. All rights reserved.

WinGet is a command line utility that allows you to install applications and other packages from the command line.

Usage: winget  [<command>] [<options>]

The following commands are valid:
  install    Install the given package
  show       Show information about a package
  source     Manage sources of packages
  search     Find and show basic information of packages
  list       List installed packages
  upgrade    Show and perform available upgrades
  uninstall  Uninstall the given package
  hash       Helper to hash installer
  validate   Validate manifest file
  settings   Open settings or set admin settings
  features   Show the status of experimental features
  export     Export the list of installed packages
  import     Install all packages from a file
  pin        Manage package pins
  configure  Configure the system to a desired state
  download   Download installer from a given package
  repair     Repair the selected package

For more detailed information on a specific command, pass it help argument. [-?]

The following options are available:
  -v,--version              Show the version of the tool
  --info                    Show general information about the tool
  -?,--help                 Show help information for the selected command
  --wait                    Prompt the user to press any key before exiting
  --logs,--open-logs        Open the default log location
  --verbose,--verbose-logs  Enable verbose logging for WinGet
  --disable-interactivity   Disable interactive prompts

More help can be found at: "https://aka.ms/winget-command-help"

Why recommend using winget#

Advantages of winget#

  • Free: It comes with Windows.
  • Simple and comprehensive functionality: winget has the functions of searching, downloading, installing, upgrading, uninstalling, and configuring software packages. For a software management tool, these are all core functions and are sufficient.
  • Convenient operation: There is no need to download and install packages from various websites. Just enter the corresponding command in the command line to easily perform various operations on software packages. No need to download a bunch of installation packages and click around, sometimes even watching progress bars.
  • Safe and reliable: The software packages installed through winget are all from Microsoft official or trusted sources, avoiding the security risks that may come from downloading software from unofficial channels, such as bundled malware or viruses.
  • Easy to learn: The commands of winget are relatively simple, and users can quickly master them with a little learning, without the need for complex programming or technical background.
  • High integration: winget can be integrated with Windows Terminal, PowerShell, or CMD, allowing users to directly use winget commands in these environments.
  • Support for multiple formats: The latest version of winget supports software packages in the .zip format, which means it can extract and run installers from .zip files or install one or more portable software packages from files, further expanding its applicability.

Disadvantages of winget#

  • Software source limitations: The software sources of winget may be limited, and sometimes the desired software packages are not included. This limits the range of choices for users, especially for those looking for specific or niche software.
  • Command line operation threshold: winget is a command line-based tool, which may have a certain learning curve for people who are not familiar with the command line. Although the commands of winget are relatively simple, some people may still find it inconvenient to use the command line for operations.
  • Update speed: The update speed of winget may not be as fast as some third-party software package management tools. This means that some newly released software packages may not be installed or updated through winget in the first time. However, for software versions, I don't recommend insisting on installing the latest version, which is a matter of personal preference.
  • Community support: Compared to some popular third-party software package management tools, the community support for winget may be relatively weak. This may make it difficult for people to find solutions or get help when encountering problems.

How to use winget#

The most common use cases of winget are searching, installing, and uninstalling commonly used software.

The commonly used winget commands are as follows:
winget search <keywords>: Search for installation packages
winget install <appname/id>: Install software
winget uninstall <appname/id>: Uninstall software
winget update: Check for software updates
winget upgrade --all: Update all software

For example, to install WeChat, you can use the search command winget search WeChat and get the above results.

PowerShell 7.4.1
PS C:\Users\cgart> winget search WeChat
Name                  ID                     Version      Match      Source
---------------------------------------------------------------------------
WeChat                Tencent.WeChat         3.9.9.43     Tag: WeChat winget
PS C:\Users\cgart>

Because there are many installation packages with the keyword "WeChat," when installing a specific package, you should enter the ID of the installation package. The ID of WeChat is Tencent.WeChat, so we enter the command winget install Tencent.WeChat. WeChat will be installed automatically, making the whole process convenient, safe, and quiet.

By extrapolation, you can try using other commands to search, install, update, and uninstall software.

Automated Installation Script#

Although we only need to type a few letters and no longer need to search and download commonly used installation packages in the browser, it is still troublesome to type commands line by line every time the system is reinstalled. Therefore, I wrote an installation script that automatically runs commands and put it on GitHub. It can be downloaded and used for free. Here is the link

The structure of the entire script is actually very simple:

@echo off

REM Check if the software list file exists
if not exist "software_list.txt" (
    echo Software list file does not exist! Please create the software list file and run the script again.
    exit /b
)

REM Read the software list file line by line and install the software
for /f "tokens=*" %%a in (software_list.txt) do (
    echo Installing software: %%a
    winget install %%a 
)

echo All software is already installed!
pause

This way, every time you face a freshly reinstalled system or a newly purchased computer, you only need to run this script to install commonly used software at once.

All the lists are saved in this txt document, with each line representing a software ID. When the script is run, it will read each line of the ID and execute the installation command. Note that if the software is already installed, it will check for updates and upgrade to the latest version. By default, the software in the list is what I commonly use, but you can customize it according to your needs.

Oh, by the way, I also made one for Mac :) .

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.