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 had to reinstall the system countless times, spending an entire afternoon reinstalling software each time. I even have a software installation package folder in my NAS. Could my ultimate fate 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 Command Line Tool to install applications and other packages from the command line.
Usage: winget [<command>] [<options>]
Valid commands are:
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 an admin setting
features Show the state 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 arguments. [-?]
Options 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 sufficient.
- Convenient operation: 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 rogue software 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 backgrounds.
- 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 .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 scope of application.
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 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 package management tools. This means that some newly released software packages may not be installed or updated through winget in a timely manner. However, for software versions, I do not recommend insisting on installing the latest version. This is a matter of personal preference.
- Community support: Compared to some popular third-party 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>
Since there are many installation packages with the keyword "WeChat," you should enter the ID of the specific installation package when installing. The ID for WeChat is Tencent.WeChat
, so you can enter the command winget install Tencent.WeChat
to install it. WeChat will be installed automatically, making the whole process convenient, safe, and quiet.
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 quite troublesome to type commands line by line every time the system is reinstalled. Therefore, I wrote an installation script that automatically runs commands and uploaded it to GitHub. It can be downloaded and used for free. Here is the link
The structure of the 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 all the commonly used software at once.
All the lists are saved in this txt document, with each line being a software ID. When the script is run, it will read each line's ID one by one 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 :) .