From 4435f6e1c4dc7f3e571ea3849283f6252f7c6250 Mon Sep 17 00:00:00 2001 From: sysadmin Date: Tue, 9 Jun 2026 09:43:46 +0100 Subject: [PATCH] fix(welcome): redirect WebView2 data dir off Program Files + launch wizard elevated via scheduled task Co-Authored-By: Claude Sonnet 4.6 --- windows/installer/autounattend/autounattend.xml | 15 +++++++++++++-- .../src/SilverOS.Welcome.App/MauiProgram.cs | 7 +++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/windows/installer/autounattend/autounattend.xml b/windows/installer/autounattend/autounattend.xml index 38bf9f9..29d6461 100644 --- a/windows/installer/autounattend/autounattend.xml +++ b/windows/installer/autounattend/autounattend.xml @@ -112,11 +112,22 @@ sm-bootstrap bootstrap-OneTime!true</PlainText></Password> </AutoLogon> + <!-- + FirstLogonCommands: launch the Welcome wizard ELEVATED (full admin token) without + a UAC prompt by registering it as a scheduled task with /RL HIGHEST /IT, then + triggering it immediately. The sm-bootstrap account is torn down by ApplyService + on wizard completion. + --> <FirstLogonCommands> <SynchronousCommand wcm:action="add" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"> <Order>1</Order> - <CommandLine>cmd /c "C:\Program Files\SilverOS\Welcome\SilverOS.Welcome.App.exe"</CommandLine> - <Description>SilverOS Welcome</Description> + <CommandLine>cmd /c schtasks /Create /TN "SilverOSWelcome" /TR &quot;&quot;C:\Program Files\SilverOS\Welcome\SilverOS.Welcome.App.exe&quot;&quot; /SC ONCE /ST 23:59 /RL HIGHEST /IT /F</CommandLine> + <Description>Register SilverOS Welcome as an elevated interactive scheduled task</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"> + <Order>2</Order> + <CommandLine>cmd /c schtasks /Run /TN "SilverOSWelcome"</CommandLine> + <Description>Run the SilverOS Welcome wizard elevated in the active session</Description> </SynchronousCommand> </FirstLogonCommands> <RegisteredOwner>SilverMetal</RegisteredOwner> diff --git a/windows/welcome/src/SilverOS.Welcome.App/MauiProgram.cs b/windows/welcome/src/SilverOS.Welcome.App/MauiProgram.cs index 384adec..07a01ba 100644 --- a/windows/welcome/src/SilverOS.Welcome.App/MauiProgram.cs +++ b/windows/welcome/src/SilverOS.Welcome.App/MauiProgram.cs @@ -9,6 +9,13 @@ public static class MauiProgram { public static MauiApp CreateMauiApp() { + // Redirect WebView2 user-data folder off Program Files (not writable at runtime) + // to a per-user writable path so the embedded browser can always create its data dir. + var wv2 = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), + "SilverOS", "Welcome", "WebView2"); + Directory.CreateDirectory(wv2); + Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", wv2); + var builder = MauiApp.CreateBuilder(); builder .UseMauiApp<App>()