winget
一、 winget安装
-
执行命令检测是否存在winget
winget
-
不存在执行命令安装 winget
#请从 Windows PowerShell 命令提示符执行以下步骤: $progressPreference = 'silentlyContinue' Write-Information "Downloading WinGet and its dependencies..." Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx Invoke-WebRequest -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.7.3/Microsoft.UI.Xaml.2.7.x64.appx -OutFile Microsoft.UI.Xaml.2.7.x64.appx Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx Add-AppxPackage Microsoft.UI.Xaml.2.7.x64.appx Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
二、 winget配置 非必须配置项
-
winget ,tab键补全功能 只有在 powershell 窗口可以用
# 在命令窗口执行如下命令 notepad.exe $PROFILE # 打开的文件中天添加如下命令 Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock { param($wordToComplete, $commandAst, $cursorPosition) [Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new() $Local:word = $wordToComplete.Replace('"', '""') $Local:ast = $commandAst.ToString().Replace('"', '""') winget complete --word="$Local:word" --commandline "$Local:ast" --position $cursorPosition | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) } }
2.自定义样式
# cmd 命令窗口执行 winget settings # 自定义配置文件 portablePackageUserRoot 自定义配置 { "$schema": "https://aka.ms/winget-settings.schema.json", // For documentation on these settings, see: https://aka.ms/winget-settings "source": { "autoUpdateIntervalInMinutes": 5 }, "experimentalFeatures": { "dependencies": true, "directMSI": false, "zipInstall": false, }, "visual": { "progressBar": "rainbow" }, "installBehavior": { "portablePackageUserRoot": "D:/Download/Packages", "portablePackageMachineRoot": "C:/Download/Packages/Portable", "preferences": { "scope": "machine" }, "purgePortablePackage": true }, "logging": { "level": "info" } }
三、安装卸载命令
-
帮助命令
winget --help winget install --help winget list --help .... # --help 可以查看操作参数
-
安装命令
# 查询所需要的镜像源 -name 表示根据名称查询 winget search --name 网易云音乐 # 安装软件 --id 表示根据id匹配, -L 表示安装地点 winget install --id Tencent.QOMusic -l D:Download\QOMusic
-
卸载命令
#查询要卸载的软件,查询所有 winget list #根据名称 查询自己已经安装的软件 winget list --name 音乐 #卸载软件 --id 根据id 卸载软件 winget uninstall --id 网易云音乐