From 04dab4b03732d2046109edd1b5f99e62d36994f3 Mon Sep 17 00:00:00 2001 From: Simone Date: Tue, 9 Jun 2026 23:59:41 +0200 Subject: [PATCH] fix(deploy-win): wallpaper reg add hung post-install (PS 5.1 empty-arg) PowerShell 5.1 strips an empty-string argument ('') when invoking a native exe, so `reg add ... /d '' /f` reached reg.exe as `reg add ... /d /f`: reg consumed /f as the data value, lost the force flag, and prompted "overwrite? (Yes/No)" on stdin. FirstLogon runs headless with no stdin, so post-install hung forever right after the "Explorer UX tweaks applied" log line. Route both empty-value reg adds (HKCU + Default hive) through `cmd /c`, which preserves the empty "" so the value is set and /f stays. Regression from 8095f00 (wallpaper removal feature). --- .../winimage/assets/post-install.win.ps1.tmpl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ci_orchestrator/winimage/assets/post-install.win.ps1.tmpl b/src/ci_orchestrator/winimage/assets/post-install.win.ps1.tmpl index dfe252e..97196f3 100644 --- a/src/ci_orchestrator/winimage/assets/post-install.win.ps1.tmpl +++ b/src/ci_orchestrator/winimage/assets/post-install.win.ps1.tmpl @@ -264,7 +264,11 @@ reg add 'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' /v La L 'Explorer UX tweaks applied (HKCU)' # ── No desktop wallpaper (keep the WS2025 default background colour) ────── -reg add 'HKCU\Control Panel\Desktop' /v Wallpaper /t REG_SZ /d '' /f | Out-Null +# NOTE: route the empty-value reg add through cmd /c. PowerShell 5.1 STRIPS an +# empty-string argument ('') when calling a native exe, so `reg add ... /d '' /f` +# would arrive as `reg add ... /d /f` — reg then eats /f as the data, loses the +# force flag, and PROMPTS "overwrite? (Yes/No)" on stdin → the script hangs. +cmd /c 'reg add "HKCU\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d "" /f' | Out-Null reg add 'HKCU\Control Panel\Desktop' /v WallpaperStyle /t REG_SZ /d 0 /f | Out-Null L 'Wallpaper removed (default background colour, HKCU)' @@ -284,7 +288,8 @@ reg add 'HKU\DefaultUser2\Software\Microsoft\Windows\CurrentVersion\Explorer\Adv reg add 'HKU\DefaultUser2\Console\%Startup' /v DelegationConsole /t REG_SZ /d '{E12CFF52-A866-4C77-9A90-F570A7AA2C6B}' /f | Out-Null reg add 'HKU\DefaultUser2\Console\%Startup' /v DelegationTerminal /t REG_SZ /d '{E12CFF52-A866-4C77-9A90-F570A7AA2C6B}' /f | Out-Null # No wallpaper (keep default background colour) for any future profile. -reg add 'HKU\DefaultUser2\Control Panel\Desktop' /v Wallpaper /t REG_SZ /d '' /f | Out-Null +# cmd /c for the empty value — see PS-5.1 empty-arg note in the HKCU block above. +cmd /c 'reg add "HKU\DefaultUser2\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d "" /f' | Out-Null reg add 'HKU\DefaultUser2\Control Panel\Desktop' /v WallpaperStyle /t REG_SZ /d 0 /f | Out-Null reg unload HKU\DefaultUser2 2>&1 | Out-Null L 'Taskbar: search hidden, task view hidden, WT default terminal, no wallpaper'