From 9c1131db853c01676d502ad545527cbdb3e46c42 Mon Sep 17 00:00:00 2001 From: Divya Date: Thu, 6 Aug 2026 13:51:34 +0530 Subject: [PATCH 1/3] fix(#558): write Docker Desktop autostart for a provisioned daily user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set-DailyUserProvisioning only wrote the HKCU Run key when the provisioned user was the account running the installer ($user -eq $env:USERNAME). For a provisioned DIFFERENT daily user (the hospital IT-installs-elevated case), their registry hive isn't loaded, so no autostart was written and the code relied on --always-run-service. On the WSL2 backend dockerd runs inside the docker-desktop distro that the Docker Desktop GUI boots, so without the GUI autostarting on that user's login the engine isn't up after a reboot and the k3d containers have no daemon to restart into — the client is down until someone opens Docker Desktop manually. For the provisioned different user, drop a "Docker Desktop.lnk" into their Startup folder (same launch-at-logon mechanism as the Run key, no hive load needed). When they have no profile yet, name the one-click GUI setting to flip after first sign-in. The current-user Run-key path is unchanged. Co-Authored-By: Claude Opus 4.8 --- scripts/install-k8s.ps1 | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/scripts/install-k8s.ps1 b/scripts/install-k8s.ps1 index 7d72eaf2..dd0d1641 100644 --- a/scripts/install-k8s.ps1 +++ b/scripts/install-k8s.ps1 @@ -2124,15 +2124,47 @@ function Set-DailyUserProvisioning { } } catch { Log "docker-users add failed: $_" } - # 2) Docker Desktop autostart via the per-user Run key (current user only -- a - # different user's hive may not be loaded). The engine also runs as a service - # (--always-run-service, #419), so Docker is usable on sign-in regardless. + # 2) Docker Desktop autostart. On the WSL2 backend, dockerd runs INSIDE the + # docker-desktop distro that the Docker Desktop GUI boots; without the GUI + # autostarting on the daily user's login, the engine isn't up after a reboot, + # so the k3d containers (which carry --restart unless-stopped) have no daemon + # to restart into and the client is down until someone opens Docker Desktop + # manually (#558). For the CURRENT user the per-user Run key is simplest. For + # a PROVISIONED DIFFERENT user (the hospital IT-installs-elevated case), their + # registry hive isn't loaded, so the Run key can't be written for them; drop a + # shortcut into THEIR Startup folder instead — the same "launch at this user's + # logon" mechanism, no hive needed. --always-run-service (#419) is kept as a + # backstop, but its headless-engine behaviour is Docker-Desktop-version + # dependent, so autostart is no longer left to it alone for the second user. try { $ddExe = "$env:ProgramFiles\Docker\Docker\Docker Desktop.exe" - if ($user -eq $env:USERNAME -and (Test-Path $ddExe)) { + if (-not (Test-Path $ddExe)) { + Log "autostart skipped: Docker Desktop not found at $ddExe" + } elseif ($user -eq $env:USERNAME) { New-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run' ` -Name 'Docker Desktop' -Value "`"$ddExe`"" -PropertyType String -Force -ErrorAction Stop | Out-Null $did += "autostart enabled" + } else { + $profileDir = Get-UserProfileDir -User $user + if ($null -eq $profileDir) { + # Never signed in -> no profile/Startup folder to write into. Name the + # one-click GUI setting they can flip after first sign-in. + $did += "no profile for '$user' yet -- have them enable Docker Desktop's 'Start Docker Desktop when you sign in' (Settings > General) after first sign-in" + } else { + $startupDir = Join-Path $profileDir 'AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup' + if (-not (Test-Path $startupDir)) { New-Item -ItemType Directory -Path $startupDir -Force -ErrorAction Stop | Out-Null } + $lnkPath = Join-Path $startupDir 'Docker Desktop.lnk' + $wsh = New-Object -ComObject WScript.Shell + try { + $sc = $wsh.CreateShortcut($lnkPath) + $sc.TargetPath = $ddExe + $sc.WorkingDirectory = (Split-Path $ddExe) + $sc.Save() + } finally { + [System.Runtime.InteropServices.Marshal]::ReleaseComObject($wsh) | Out-Null + } + $did += "autostart enabled (Startup shortcut in '$user's profile)" + } } } catch { Log "autostart set failed: $_" } From dc53247e4a3da33f98d90adc06b00a8660f1c666 Mon Sep 17 00:00:00 2001 From: Divya Date: Thu, 6 Aug 2026 16:06:05 +0530 Subject: [PATCH 2/3] chore(installer): refresh manifest.sha256 for changed install-k8s.ps1 (#558) scripts/install-k8s.ps1 changed in this branch; regenerate the signed integrity manifest via scripts/gen-manifest.sh so the "Static analysis" gate (gen-manifest.sh --check) passes. Co-Authored-By: Claude Opus 4.8 --- scripts/manifest.sha256 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/manifest.sha256 b/scripts/manifest.sha256 index 1edcbe0a..25a410f2 100644 --- a/scripts/manifest.sha256 +++ b/scripts/manifest.sha256 @@ -15,4 +15,4 @@ e373403d7bb5ce3728b8d21af89e6bf672cc35bbf8938541eb527ae19cb9473b scripts/lib/as 911fd0714b17357bb205fc8a8fa8e13eedc1a9632a2f63d4ead9f8d8c7ee546f scripts/lib/probe.sh 38761a6c56dc85b3f5742df036e6a2ec2baa0adb0c90b3753b6706779528b7be scripts/lib/summary.sh 77e03332ebfab1ef759c6148a57afcf479c02c5dc6cc7b0e0e680f58e20cd364 scripts/lib/diagnose.sh -35745834c814b03950f6e6a36d3df40fadec51f8f9fe743b6d647a8eedd3679c scripts/install-k8s.ps1 +b6340c82316d9782dfb14bf2cf2993304b79f1b7d4c17d7fe56b99e766c39d86 scripts/install-k8s.ps1 From 2dd9e6c4b85010778edbe00de72b9107917f13c4 Mon Sep 17 00:00:00 2001 From: Divya Date: Thu, 6 Aug 2026 16:34:01 +0530 Subject: [PATCH 3/3] fix(#558): surface autostart failures instead of a silent green summary The cross-user Docker Desktop autostart path (Startup-folder shortcut for a provisioned DIFFERENT daily user) can fail on Startup-dir creation, the WScript.Shell COM object, or saving the .lnk. It was caught by the outer `catch { Log ... }`, which logged but added nothing to $did. With docker-users succeeding, the summary then printed a green "Configured for '$user'" with no autostart note -- so IT left the elevated window thinking #558 was handled while the daily user still had no autostart and the client is down after every reboot. Append a manual-step note to $did on failure, mirroring the .wslconfig catch in the same function, and name the one-click GUI remediation. Add source-guard Pester tests for the Startup-shortcut feature and the new failure-note path; refresh manifest.sha256. Co-Authored-By: Claude Opus 4.8 --- scripts/install-k8s.ps1 | 12 +++++++++++- scripts/manifest.sha256 | 2 +- scripts/tests/install-k8s.Tests.ps1 | 15 +++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/scripts/install-k8s.ps1 b/scripts/install-k8s.ps1 index dd0d1641..ba1af6de 100644 --- a/scripts/install-k8s.ps1 +++ b/scripts/install-k8s.ps1 @@ -2166,7 +2166,17 @@ function Set-DailyUserProvisioning { $did += "autostart enabled (Startup shortcut in '$user's profile)" } } - } catch { Log "autostart set failed: $_" } + } catch { + # A thrown COM/dir/permission failure here (creating the Startup folder, the + # WScript.Shell COM object, or saving the .lnk) must surface in the summary too + # -- otherwise docker-users succeeding prints a green "Configured for" with no + # autostart note, and IT leaves the elevated window thinking the daily user is + # ready while Docker Desktop won't launch on their login and the client is down + # after every reboot (#558 Bugbot). Mirror the .wslconfig catch below: log AND + # append a manual-step note to $did so the summary is honest about what's left. + Log "autostart set failed: $_" + $did += "couldn't set Docker Desktop autostart -- have '$user' enable Docker Desktop's 'Start Docker Desktop when you sign in' (Settings > General)" + } # 3) Training-sized .wslconfig in the daily user's profile. Merge the memory # budget in without clobbering any other tuning (processors/swap/...), and keep diff --git a/scripts/manifest.sha256 b/scripts/manifest.sha256 index 25a410f2..633fa3aa 100644 --- a/scripts/manifest.sha256 +++ b/scripts/manifest.sha256 @@ -15,4 +15,4 @@ e373403d7bb5ce3728b8d21af89e6bf672cc35bbf8938541eb527ae19cb9473b scripts/lib/as 911fd0714b17357bb205fc8a8fa8e13eedc1a9632a2f63d4ead9f8d8c7ee546f scripts/lib/probe.sh 38761a6c56dc85b3f5742df036e6a2ec2baa0adb0c90b3753b6706779528b7be scripts/lib/summary.sh 77e03332ebfab1ef759c6148a57afcf479c02c5dc6cc7b0e0e680f58e20cd364 scripts/lib/diagnose.sh -b6340c82316d9782dfb14bf2cf2993304b79f1b7d4c17d7fe56b99e766c39d86 scripts/install-k8s.ps1 +350fa54afc491ed353fecae7bbe42ad6c24be8d28915b7aeefdac27626536339 scripts/install-k8s.ps1 diff --git a/scripts/tests/install-k8s.Tests.ps1 b/scripts/tests/install-k8s.Tests.ps1 index b88cf79d..6fa892a7 100644 --- a/scripts/tests/install-k8s.Tests.ps1 +++ b/scripts/tests/install-k8s.Tests.ps1 @@ -171,6 +171,21 @@ Describe "Daily-user provisioning wiring (#418 source guards)" { It "notes .wslconfig as a manual step when the write itself throws (no silent catch)" { $script:PSRC | Should -Match "couldn't write .wslconfig" } + It "autostarts Docker Desktop for a provisioned DIFFERENT user via a Startup-folder shortcut (#558)" { + # A different user's hive isn't loaded, so the per-user Run key can't be written + # for them; a .lnk in THEIR Startup folder is the hive-free equivalent. + $script:PSRC | Should -Match 'CreateShortcut' + $script:PSRC | Should -Match 'Start Menu\\Programs\\Startup' + $script:PSRC | Should -Match 'autostart enabled \(Startup shortcut' + } + It "notes autostart as a manual step when the Startup-shortcut path throws (no silent catch) (#558)" { + # COM/dir/permission failures in the cross-user autostart path must append a + # manual-step note to $did, mirroring the .wslconfig catch -- otherwise + # docker-users succeeding prints a green "Configured for" with no autostart note + # and IT leaves thinking the daily user is ready while Docker Desktop won't launch. + $script:PSRC | Should -Match "couldn't set Docker Desktop autostart" + $script:PSRC | Should -Match "Start Docker Desktop when you sign in" + } It "sanitizes the prompted daily-user name before it hits net localgroup + paths" { $script:PSRC | Should -Match '\$other = ConvertTo-SanitizedInput \$other' }