From 9efa3c6579fe5b193fa72b8e717a0bfac014d0f0 Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Wed, 19 Aug 2026 10:19:10 +0000 Subject: [PATCH] [client] Start the restarted UI with the user's environment block (#7245) The updater runs as LocalSystem and started netbird-ui via CreateProcessAsUser with a nil environment, so the UI inherited the SYSTEM environment (USERPROFILE, APPDATA pointing at systemprofile) while running under the user's token. The WebView2-based UI exits immediately in that state, so the UI never came back after an update. Build the environment from the user's token with CreateEnvironmentBlock and pass it to CreateProcessAsUser. --- .../updater/installer/installer_run_windows.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/client/internal/updater/installer/installer_run_windows.go b/client/internal/updater/installer/installer_run_windows.go index 81da211b6..b2ecf3299 100644 --- a/client/internal/updater/installer/installer_run_windows.go +++ b/client/internal/updater/installer/installer_run_windows.go @@ -307,6 +307,16 @@ func startUIInSession(uiPath string, sessionID uint32) error { } }() + var env *uint16 + if err := windows.CreateEnvironmentBlock(&env, primaryToken, false); err != nil { + return fmt.Errorf("create environment block: %w", err) + } + defer func() { + if err := windows.DestroyEnvironmentBlock(env); err != nil { + log.Warnf("failed to destroy environment block: %v", err) + } + }() + // Prepare startup info var si windows.StartupInfo si.Cb = uint32(unsafe.Sizeof(si)) @@ -329,7 +339,7 @@ func startUIInSession(uiPath string, sessionID uint32) error { nil, false, creationFlags, - nil, + env, nil, &si, &pi,