Install Ubuntu automatically
This commit is contained in:
parent
9ecac43db8
commit
8a06f62b85
|
@ -63,9 +63,14 @@ function Install-Wsl {
|
|||
function Install-WslDistribution {
|
||||
$dir = Get-WslDistributionPath;
|
||||
$root = Split-Path -Parent $dir;
|
||||
$ubuntuPattern = "*Ubuntu*";
|
||||
$registryPath = "HKCU:/Software/Microsoft/Windows/CurrentVersion/Lxss";
|
||||
$key = Get-Item $registryPath;
|
||||
|
||||
if (Get-AppxPackage $ubuntuPattern) {
|
||||
Install-Wsl;
|
||||
}
|
||||
|
||||
if ($key) {
|
||||
$key = $key | Rename-Item -NewName "$(Split-Path -Leaf $key)_" -PassThru;
|
||||
}
|
||||
|
@ -74,7 +79,7 @@ function Install-WslDistribution {
|
|||
$null = New-Item -ItemType Directory $root;
|
||||
}
|
||||
|
||||
Copy-Item -Recurse -Force (Get-AppxPackage "*Ubuntu*").InstallLocation $dir;
|
||||
Copy-Item -Recurse -Force (Get-AppxPackage $ubuntuPattern).InstallLocation $dir;
|
||||
Set-UserPermissions $dir;
|
||||
& "$dir\ubuntu.exe" install --root;
|
||||
wsl --shutdown;
|
||||
|
|
Loading…
Reference in a new issue