免互動安裝Yarn、解除安裝,以及在部署工具中偵測安裝狀態所用的指令。只列出確定可用的指令:來自資訊清單,或是安裝程式技術的官方預設參數。
相關教學: 靜默安裝參數總整理:MSI、NSIS、Inno Setup · 用登錄檔或PowerShell解除安裝程式
使用winget
PowerShell
winget install --id Yarn.Yarn -e --silent --accept-package-agreements --accept-source-agreementswinget upgrade --id Yarn.Yarn -e --silentwinget uninstall --id Yarn.Yarn -e --silent依安裝檔
32位元 · MSI · 所有使用者 · en-US
靜默安裝
msiexec /i yarn-1.22.22.msi /qn /norestart寫入記錄檔
msiexec /i yarn-1.22.22.msi /qn /norestart /l*v "%TEMP%\yarn-install.log"解除安裝
msiexec /x {9C4264B2-06A3-4D5E-99B8-6EC942052E5D} /qn /norestart- MSI產品代碼
- {9C4264B2-06A3-4D5E-99B8-6EC942052E5D}
- 解除安裝登錄機碼
- HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{9C4264B2-06A3-4D5E-99B8-6EC942052E5D}
- UpgradeCode
- {241362E6-53BB-4A50-9C58-15F95734E43D}
PowerShell:下載、驗證、安裝
下載官方檔案,驗證SHA256後靜默安裝。
install-yarn.ps1
$url = 'https://github.com/yarnpkg/yarn/releases/download/v1.22.22/yarn-1.22.22.msi'
$sha256 = 'EBC1F46891B8D507EFAD2DD18EEC2C4E617457F93E13BC701483CB047A053FA1'
$file = Join-Path $env:TEMP 'yarn-1.22.22.msi'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Start-Process msiexec.exe -ArgumentList '/i', ('"{0}"' -f $file), '/qn', '/norestart' -Wait