Initialize operation for all users

This commit is contained in:
Manuel Thalmann 2024-08-27 04:24:29 +02:00
parent 1b0c715514
commit 3185e67a59
4 changed files with 25 additions and 10 deletions
scripts/Windows/Scripts

View file

@ -55,6 +55,13 @@ function Install-Wsl {
function Install-WslDistribution {
$dir = Get-WslDistributionPath;
$root = Split-Path -Parent $dir;
$registryPath = "HKCU:/Software/Microsoft/Windows/CurrentVersion/Lxss";
$key = Get-Item $registryPath;
wsl --shutdown;
if ($key) {
$key = $key | Rename-Item -NewName "$(Split-Path -Leaf $key)_" -PassThru;
}
if (-not (Test-Path $root)) {
$null = New-Item -ItemType Directory $root;
@ -64,6 +71,11 @@ function Install-WslDistribution {
Set-UserPermissions $dir;
& "$dir\ubuntu.exe" install --root;
wsl --shutdown;
Remove-Item -Recurse -Force $registryPath;
if ($key) {
Move-Item $key.PSPath $registryPath;
}
}
<#