Fix the issue where the winget command is not found.
Microsoft's official package manager, winget, is used in Windows 10 version 1809 and above for quickly installing, updating, and managing applications. This article addresses the issue where the winget command fails due to changes in the system environment, analyzes possible causes, and provides solutions and preventive measures, including repair commands, regular update checks, and backup of environment variables.
目录9 个章节
Preface
winget is Microsoft's official Windows package manager, which is typically automatically included in Windows 10 version 1809 and later. It allows you to quickly install, update, and manage applications through the command line and is a highly practical tool within the Windows ecosystem.
Problem Description
My computer previously had my environment configured and I had been using winget stably for a long time. However, recently when I execute winget commands, it suddenly started giving errors:
winget: The term 'winget' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Possible Causes
- Windows Update may have unexpectedly modified system environment variables
- The App Installer component may have been accidentally uninstalled or corrupted
- The winget executable file in the system path may have been moved or deleted
- User permission issues prevent access to winget
Although reinstalling can solve the problem, considering the time cost and existing configuration, I decided to seek a more efficient repair solution.
Detailed Repair Steps
Step 1: Try Installing the WinGet Client Module
Based on community recommendations, first attempt to install the Microsoft.WinGet.Client PowerShell module:
Run PowerShell as Administrator
Install-Module -Name Microsoft.WinGet.Client -Force
This module provides additional winget management capabilities, but installing it alone does not resolve our issue.
### Step 2: Execute Repair Command
The truly effective solution is to use the repair command that comes with the Windows package manager:
```powershell
# Run PowerShell as Administrator
```powershell
Repair-WinGetPackageManager
This command will:
- Check and repair the App Installer component
- Re-register winget-related components
- Restore system environment variable settings
After execution, it is recommended to restart your computer to ensure all changes take effect.
Preventive Measures and Maintenance Suggestions
- Regularly Check Updates: Keep Windows and App Installer up to date.
- Back Up Environment Variables: Export the PATH environment variable as a backup.
- Create System Restore Points: Before making major system changes, create a restore point.
- Use winget export: Periodically export the list of installed software.
Further Reading
FAQ
Q: What to do if the fix command still doesn't work? A: You can try manually installing the latest version of App Installer or fully reinstalling winget.
Q: How to verify if winget is working properly?
A: Run winget --version to check the version number, or winget search to test the search functionality.
_EOF_
Fix the issue where the winget command is not found.
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
用 dnot.sh 替代 Windows Defender
dnot.sh 往安全中心塞了个假 AV 签名,Defender 就乖乖下岗了——至少监控上看。实际还得再跑 extra-strip.bat 才能真关,这两步缺一不可,属实有点折腾。搞定即裸奔,胆子小的别碰。
2026-09-17 · Windows · 约 1 分钟
使用twinkle-tray快捷调整多个显示器的亮度
自从安装了这个小工具,我再也没用过笔记本键盘上的快捷键了~
2025-01-26 · Windows · 约 1 分钟
在Windows上将git与ssh-agent搭配使用
Windows git 还自带 ssh?真是老土的兼容性思路。一行配置就能解决,不过得先管好 ssh-agent 的连接。 ProxyCommand 居然又添乱,难怪老出毛病。
2025-08-21 · Windows · 约 1 分钟
解决Windows蓝牙耳机音质差的问题
Windows 把蓝牙耳机麦克风一调用就切 HFP,全损音质,真当用户听不出来?mmsys.cpl 里把录制设备禁掉,世界清净。这破系统还得手动治。
2026-11-12 · Windows · 约 1 分钟
讨论
共 0 条加载评论中…