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 许可协议。转载请注明出处!
相关文章
在 Windows 10 上实现免密码 SSH 登录
在日常开发中,SSH(Secure Shell)作为一种安全的远程登录协议,广泛用于 Linux 和 Windows 系统之间的连接。为了提高效率,我们可以通过配置免密码登录,省去每次连接时输入密码的繁琐过程。
2026-08-25 · Windows · 约 1 分钟
Kali-Linux-on-WSL2安装与简单配置指南
Windows在更新到2004版本之后正式开启了WSL2的支持,这次是完整的运行在HyperV虚拟机中的Linux系统了,可以称之为真正的Linux了,难不成Windows即将成为最好的Linux发行版? 实际体验下来还是可以的,不过小问题不少,爱折腾的同学安排一手,对提高Windows平台下的开发体验还是有很大帮助的~ Kali on WSL2安装指南 升级系统 首先检查当前系统版本,按Win+
2021-12-18 · Windows · 约 1 分钟
忘记WSL的root密码怎么办
解决方法 首先,打开WSL是不需要输入密码的,如果你打开WSL时的默认用户不是root,请按照一下方式修改。 修改默认登录WSL用户 以管理员权限启动Powershell lxrun /setdefaultuser root 此时重新打开WSL就是root用户了,并且不需要密码。 然后输入以下命令修改密码。 passwd root About 了解更多有趣的操作请关注我的微信公众号:DealiA
2021-12-18 · Windows · 约 1 分钟
使用EarTrumpet代替windows默认的音量调节功能
Windows 默认的音量调节功能挺弱的,要分别调节各个应用的音量得进入二级菜单,麻烦得很。有了这个功能就很方便了
2025-01-26 · Windows · 约 1 分钟
讨论
共 0 条加载评论中…