Skip to content

Commit 52bad1f

Browse files
authored
Add script and instructions to install the latest version of WSL when the machine is in a bad MSIX state (#11500)
1 parent b79d1d5 commit 52bad1f

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

triage/config.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ rules:
9090
name: user-visible-error
9191
capture:
9292
field3: error
93+
94+
- logline:
95+
provider: Microsoft.Windows.Subsystem.Lxss
96+
task: UserVisibleError
97+
field3: Wsl/CallMsi/REGDB_E_CLASSNOTREG
98+
set: msix-bad-install-state
9399

94100
- logline:
95101
provider: Microsoft-Windows-Hyper-V-Chipset
@@ -271,3 +277,17 @@ actions:
271277
condition: msix-install-error
272278
debug_message: 'Found evidence of MSIX install error: $error, adding msix tag'
273279
tag: 'msix'
280+
281+
- when:
282+
condition: msix-bad-install-state
283+
user_message: |
284+
Your WSL installation appears to be in a bad state. Can you try running the following command to reinstall WSL (elevated powershell) and see if that solves the issue?
285+
286+
```
287+
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/triage/install-latest-wsl.ps1" -OutFile install-latest-wsl.ps1
288+
Set-ExecutionPolicy Bypass -Scope Process -Force
289+
.\install-latest-wsl.ps1
290+
```
291+
292+
293+
tag: 'msix'

triage/install-latest-wsl.ps1

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#Requires -RunAsAdministrator
2+
3+
# This script downloads and installs the latest version of the WSL MSI package
4+
5+
$ErrorActionPreference = "Stop"
6+
Set-StrictMode -Version Latest
7+
8+
$release = Invoke-WebRequest 'https://api.github.com/repos/microsoft/WSL/releases/latest' | ConvertFrom-Json
9+
$systeminfo = & systeminfo | findstr /C:"System Type"
10+
if ($systeminfo.contains('x64'))
11+
{
12+
$target = '.x64.msi'
13+
} elseif ($systeminfo.contains('arm64'))
14+
{
15+
$target = '.arm64.msi'
16+
} else
17+
{
18+
throw 'Failed to determine system type ($systeminfo)'
19+
}
20+
21+
[array]$assets = $release.assets | Where-Object { $_.name.ToLower().endswith('.x64.msi')}
22+
if ($assets.count -ne 1)
23+
{
24+
throw 'Failed to find asset ($assets)'
25+
}
26+
27+
$target = "$env:tmp\$($assets.name)"
28+
Write-Host "Downloading $($assets.name) to $target"
29+
30+
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
31+
$headers.Add('Accept','application/octet-stream')
32+
33+
Invoke-WebRequest $assets.url -Out $target -Headers $headers
34+
35+
$MSIArguments = @(
36+
"/i"
37+
$target
38+
"/qn"
39+
"/norestart"
40+
)
41+
42+
$exitCode = (Start-Process -Wait "msiexec.exe" -ArgumentList $MSIArguments -NoNewWindow -PassThru).ExitCode
43+
if ($exitCode -Ne 0)
44+
{
45+
throw "Failed to install package: $exitCode"
46+
}
47+
48+
Write-Host 'Installation complete'
49+
50+
Remove-Item $target -Force

0 commit comments

Comments
 (0)