From 41ab01a2eaff4d4c0fc88d56a0027d1244c33e82 Mon Sep 17 00:00:00 2001 From: zm-oai Date: Fri, 21 Aug 2026 16:41:41 +0000 Subject: [PATCH] Fix elevated Windows sandbox setup activation (#39971) ## Why Sandbox setup runs on a Tokio worker thread without a Windows message loop, so `ShellExecuteExW` requires synchronous activation when launching the elevated setup helper. ## What changed Add `SEE_MASK_NOASYNC` to the shell execution flags while retaining `SEE_MASK_NOCLOSEPROCESS` for helper process tracking. GitOrigin-RevId: 875cc1d49bb19f92f940633b6315711143beeae7 --- codex-rs/windows-sandbox-rs/src/setup.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/codex-rs/windows-sandbox-rs/src/setup.rs b/codex-rs/windows-sandbox-rs/src/setup.rs index 4a5f403e5b..361a565a24 100644 --- a/codex-rs/windows-sandbox-rs/src/setup.rs +++ b/codex-rs/windows-sandbox-rs/src/setup.rs @@ -911,6 +911,7 @@ fn run_setup_exe_payload( use windows_sys::Win32::System::Threading::GetExitCodeProcess; use windows_sys::Win32::System::Threading::INFINITE; use windows_sys::Win32::System::Threading::WaitForSingleObject; + use windows_sys::Win32::UI::Shell::SEE_MASK_NOASYNC; use windows_sys::Win32::UI::Shell::SEE_MASK_NOCLOSEPROCESS; use windows_sys::Win32::UI::Shell::SHELLEXECUTEINFOW; use windows_sys::Win32::UI::Shell::ShellExecuteExW; @@ -967,7 +968,9 @@ fn run_setup_exe_payload( let verb_w = crate::winutil::to_wide("runas"); let mut sei: SHELLEXECUTEINFOW = unsafe { std::mem::zeroed() }; sei.cbSize = std::mem::size_of::() as u32; - sei.fMask = SEE_MASK_NOCLOSEPROCESS; + // Sandbox setup runs on a Tokio worker without a Windows message loop. + // ShellExecuteEx requires synchronous activation on such threads. + sei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC; sei.lpVerb = verb_w.as_ptr(); sei.lpFile = exe_w.as_ptr(); sei.lpParameters = params_w.as_ptr();