免互動安裝Windows Subsystem for Linux、解除安裝,以及在部署工具中偵測安裝狀態所用的指令。只列出確定可用的指令:來自資訊清單,或是安裝程式技術的官方預設參數。
相關教學: 靜默安裝參數總整理:MSI、NSIS、Inno Setup · 用登錄檔或PowerShell解除安裝程式
使用winget
PowerShell
winget install --id Microsoft.WSL -e --silent --accept-package-agreements --accept-source-agreementswinget upgrade --id Microsoft.WSL -e --silentwinget uninstall --id Microsoft.WSL -e --silent依安裝檔
64位元 · MSIX
靜默安裝
Add-AppxPackage -Path Microsoft.WSL_2.7.14.0_x64_ARM64.msixbundle解除安裝
Get-AppxPackage -Name MicrosoftCorporationII.WindowsSubsystemForLinux | Remove-AppxPackage64位元 · MSI
靜默安裝
msiexec /i wsl.2.7.14.0.x64.msi /qn /norestart寫入記錄檔
msiexec /i wsl.2.7.14.0.x64.msi /qn /norestart /l*v "%TEMP%\windows-subsystem-for-linux-install.log"解除安裝
msiexec /x {DC52CEBE-E53A-463D-98EE-81AF640914BD} /qn /norestart- MSI產品代碼
- {DC52CEBE-E53A-463D-98EE-81AF640914BD}
- 解除安裝登錄機碼
- HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{DC52CEBE-E53A-463D-98EE-81AF640914BD}
ARM64 · MSIX
靜默安裝
Add-AppxPackage -Path Microsoft.WSL_2.7.14.0_x64_ARM64.msixbundle解除安裝
Get-AppxPackage -Name MicrosoftCorporationII.WindowsSubsystemForLinux | Remove-AppxPackageARM64 · MSI
靜默安裝
msiexec /i wsl.2.7.14.0.arm64.msi /qn /norestart寫入記錄檔
msiexec /i wsl.2.7.14.0.arm64.msi /qn /norestart /l*v "%TEMP%\windows-subsystem-for-linux-install.log"解除安裝
msiexec /x {D121F6A7-AEC9-46A4-94CB-0AF3FF1B5B61} /qn /norestart- MSI產品代碼
- {D121F6A7-AEC9-46A4-94CB-0AF3FF1B5B61}
- 解除安裝登錄機碼
- HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{D121F6A7-AEC9-46A4-94CB-0AF3FF1B5B61}
PowerShell:下載、驗證、安裝
下載官方檔案,驗證SHA256後靜默安裝。
install-windows-subsystem-for-linux.ps1
$url = 'https://github.com/microsoft/WSL/releases/download/2.7.14/Microsoft.WSL_2.7.14.0_x64_ARM64.msixbundle'
$sha256 = '7BA80E0846C4E82AC3D33165C21A52D95278BAB422EF005461B5E6ACC37CE66B'
$file = Join-Path $env:TEMP 'Microsoft.WSL_2.7.14.0_x64_ARM64.msixbundle'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Add-AppxPackage -Path $file install-windows-subsystem-for-linux.ps1
$url = 'https://github.com/microsoft/WSL/releases/download/2.7.14/wsl.2.7.14.0.x64.msi'
$sha256 = 'DB084E536279A59E90A26EC598D8AA8A4DFF8309F41D078FD06242953AC1EBCD'
$file = Join-Path $env:TEMP 'wsl.2.7.14.0.x64.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 install-windows-subsystem-for-linux.ps1
$url = 'https://github.com/microsoft/WSL/releases/download/2.7.14/Microsoft.WSL_2.7.14.0_x64_ARM64.msixbundle'
$sha256 = '7BA80E0846C4E82AC3D33165C21A52D95278BAB422EF005461B5E6ACC37CE66B'
$file = Join-Path $env:TEMP 'Microsoft.WSL_2.7.14.0_x64_ARM64.msixbundle'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Add-AppxPackage -Path $file install-windows-subsystem-for-linux.ps1
$url = 'https://github.com/microsoft/WSL/releases/download/2.7.14/wsl.2.7.14.0.arm64.msi'
$sha256 = '3456D37B2F009FB075A1E35366E8B46CE13A7F8355DF63E278D68FCE319C790A'
$file = Join-Path $env:TEMP 'wsl.2.7.14.0.arm64.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