三年前寫過 Windows 新裝機 Chocolatey 安裝清單,方便新裝 Windows 時一次備足常用軟體。時代演進,微軟官方的 winget 漸成主流,成為 Windows 11、Windows Server 2025 內建工具,決定與時俱進,整理一份 winget 版。

註:Windows Sandbox 未內建 winget 與 Microsoft Store,需從 GitHub Releases 下載,或執行 Repair-WinGetPackageManager 修復

winget 常用參數如下:參考

  • --id <ID> -e 以套件 ID 精確比對(區分大小寫),可避免裝錯套件
  • -s winget 限定 winget 社群來源,避免與 msstore 重複
  • -h (或--silent) 靜默安裝,不顯示安裝程式介面
  • --accept-package-agreements 自動同意套件授權
  • --accept-source-agreements 自動同意來源使用條款
  • --scope machine 全機安裝(需系統管理員權限)
  • --disable-interactivity 停用互動提示(自動批次安裝)

不確定套件 ID 時,可先用 search 查詢:

winget search notepad++
winget show --id Notepad++.Notepad++ -e

以下是我在 Windows 幾乎一定會裝的軟體:

  1. Notepad++、7-Zip、.NET SDK
    winget install --id Notepad++.Notepad++ -e -s winget
    winget install --id 7zip.7zip -e -s winget
    winget install --id Microsoft.DotNet.SDK.10 -e -s winget
    
    註:winget 安裝 .NET SDK 需明確指定版本(如 Microsoft.DotNet.SDK.9、Microsoft.DotNet.SDK.10),不像 choco 可用 dotnet-sdk 指定「最新版」
  2. Git for Windows
    winget install --id Git.Git -e -s winget
    
    安裝後需重開終端機讓 PATH 生效,並記得設定使用者名稱及 Email:
    git config --global user.name "你的名字"
    git config --global user.email "信箱@mail-domain"
    
  3. Cmder 可被 Windows Terminal 取代,我已不再安裝
  4. Chrome
    winget install --id Google.Chrome -e -s winget
    
  5. VS Code
    winget install --id Microsoft.VisualStudioCode -e -s winget
    

想一次裝完,可寫成 PowerShell 腳本如下:

$apps = @(
  'Notepad++.Notepad++'
  '7zip.7zip'
  'Microsoft.DotNet.SDK.10'
  'Git.Git'
  'Google.Chrome'
  'Microsoft.VisualStudioCode'
)
foreach ($id in $apps) {
  winget install --id $id -e -s winget -h --accept-package-agreements --accept-source-agreements
  if ($LASTEXITCODE -ne 0) { Write-Warning "$id 安裝失敗 (0x{0:X8})" -f $LASTEXITCODE }
}


Comments

Be the first to post a comment

Post a comment