Install Ubuntu automatically
This commit is contained in:
parent
2cf84dc44c
commit
a7b40d2376
|
@ -63,8 +63,14 @@ function Install-Wsl {
|
||||||
function Install-WslDistribution {
|
function Install-WslDistribution {
|
||||||
$dir = Get-WslDistributionPath;
|
$dir = Get-WslDistributionPath;
|
||||||
$root = Split-Path -Parent $dir;
|
$root = Split-Path -Parent $dir;
|
||||||
|
$ubuntuPattern = "*Ubuntu*";
|
||||||
$registryPath = "HKCU:/Software/Microsoft/Windows/CurrentVersion/Lxss";
|
$registryPath = "HKCU:/Software/Microsoft/Windows/CurrentVersion/Lxss";
|
||||||
$key = Get-Item $registryPath;
|
$key = Get-Item $registryPath;
|
||||||
|
|
||||||
|
if (-not (Get-AppxPackage $ubuntuPattern)) {
|
||||||
|
Install-Wsl;
|
||||||
|
}
|
||||||
|
|
||||||
wsl --shutdown;
|
wsl --shutdown;
|
||||||
|
|
||||||
if ($key) {
|
if ($key) {
|
||||||
|
@ -75,7 +81,7 @@ function Install-WslDistribution {
|
||||||
$null = New-Item -ItemType Directory $root;
|
$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;
|
Set-UserPermissions $dir;
|
||||||
& "$dir\ubuntu.exe" install --root;
|
& "$dir\ubuntu.exe" install --root;
|
||||||
wsl --shutdown;
|
wsl --shutdown;
|
||||||
|
|
Loading…
Reference in a new issue