Last active
February 17, 2025 19:08
-
-
Save sanyer/399dd0c3ff304a8e765ca489fa93daa4 to your computer and use it in GitHub Desktop.
Install WSL without Windows Store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Windows now supports a simple WSL installation using the command: | |
wsl --install | |
$ErrorActionPreference = 'Continue' | |
$ProgressPreference = 'SilentlyContinue' | |
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux | |
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor | |
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform | |
Enable-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform | |
Set-Location -Path "$env:TEMP" | |
Invoke-WebRequest -Uri 'https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi' -OutFile 'wsl_update_x64.msi' -UseBasicParsing | |
Start-Process 'msiexec.exe' -Wait -ArgumentList '/I wsl_update_x64.msi /quiet' | |
Remove-Item -Path 'wsl_update_x64.msi' | |
wsl --set-default-version 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference = 'Continue' | |
$ProgressPreference = 'SilentlyContinue' | |
$WslDistName = 'ubuntu2204' | |
$WslDistFullName = 'Ubuntu-22.04' | |
$WslDistUrl = 'https://aka.ms/wslubuntu2204' | |
$WslDistExe = 'ubuntu2204.exe' | |
$WslParentDir = 'C:\Tools' | |
$WslDistPath = Join-Path -Path $WslParentDir -ChildPath $WslDistName | |
Set-Location -Path $WslParentDir | |
wsl --set-default-version 2 | |
Invoke-WebRequest -Uri "$WslDistUrl" -OutFile "$WslDistName.appx" -UseBasicParsing | |
Rename-Item -Path "$WslDistName.appx" -NewName "$WslDistName.zip" | |
Expand-Archive -Path "$WslDistName.zip" -DestinationPath "$WslDistName" | |
Remove-Item -Path "$WslDistName.zip" | |
$userenv = [System.Environment]::GetEnvironmentVariable("PATH", "User") | |
[System.Environment]::SetEnvironmentVariable("PATH", "$userenv;$WslDistPath", "User") | |
Start-Process "cmd.exe" -Wait -ArgumentList "echo /c $(Join-Path -Path "$WslDistPath" -ChildPath "$WslDistExe")" | |
wsl --set-version $WslDistFullName 2 | |
wsl --list --verbose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment