{"record":{"id":"ffb9923cda935850","repo":"zed-industries/zed","slug":"shellexecutew-failed-to-launch-elevated-process-c","errorCode":null,"errorMessage":"ShellExecuteW failed to launch elevated process (code: {result_code})","messagePattern":"ShellExecuteW failed to launch elevated process \\(code: (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/etw_tracing/etw_tracing.rs","lineNumber":611,"sourceCode":"    let file: Vec<u16> = format!(\"{}\\0\", exe_path.to_string_lossy())\n        .encode_utf16()\n        .collect();\n    let parameters: Vec<u16> = format!(\"{args}\\0\").encode_utf16().collect();\n\n    let result = unsafe {\n        ShellExecuteW(\n            None,\n            PCWSTR(operation.as_ptr()),\n            PCWSTR(file.as_ptr()),\n            PCWSTR(parameters.as_ptr()),\n            PCWSTR::null(),\n            windows::Win32::UI::WindowsAndMessaging::SW_HIDE,\n        )\n    };\n\n    let result_code = result.0 as usize;\n    if result_code <= 32 {\n        bail!(\"ShellExecuteW failed to launch elevated process (code: {result_code})\");\n    }\n\n    let (stream, _) = listener.accept().context(\"Accept subprocess connection\")?;\n\n    let mut session = EtwSession {\n        output_path: output_path.to_path_buf(),\n        stream: BufReader::new(stream),\n        listener,\n        socket_path: sock_path,\n    };\n\n    let status: StatusMessage =\n        recv_json(&mut session.stream).context(\"Wait for Started status\")?;\n\n    match status {\n        StatusMessage::Started => {}\n        StatusMessage::Error { message } => {\n            bail!(\"Subprocess reported error during start: {message}\");","sourceCodeStart":593,"sourceCodeEnd":629,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/etw_tracing/etw_tracing.rs#L593-L629","documentation":"Bailed when ShellExecuteW with the elevated ('runas') launch fails to start the ETW helper subprocess; the raw result code (<= 32) is included. Those codes are the standard ShellExecuteW SE_ERR_* values, e.g. 2 = file not found, 3 = path not found, 5 = access denied (including UAC declined), 31 = no association, 32 = missing DLL.","triggerScenarios":"The user declines the UAC prompt; the helper executable or its directory is missing at the path passed to ShellExecuteW; group policy blocks elevation; the process runs in a non-interactive session (service/CI) where no UAC prompt can appear.","commonSituations":"CI or service contexts with no interactive desktop; wrong install layout so the helper path is invalid; antivirus blocking the elevated spawn; standard-user accounts forbidden from elevating.","solutions":["Map the code: 2/3 = helper exe or path missing, 5 = access denied or UAC declined, 31/32 = association/DLL problems","Verify the helper binary exists at the exact path passed to ShellExecuteW and is executable","Accept the UAC prompt, or launch the parent from an already-elevated shell so no prompt is needed","In non-interactive sessions, run the tracing pipeline from an administrator terminal instead of relying on runas"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Before attempting runas elevation, check whether the process is already elevated\n// (e.g. via token-elevation check) and skip ShellExecuteW when it is;\n// in non-interactive sessions, skip elevation entirely and surface a clear message.","typeGuard":null,"tryCatchPattern":"Catch the bail and map the embedded SE_ERR code (2/3 missing path, 5 denied or UAC declined, 31/32 association/DLL) to a user-actionable message; offer retry so the user can accept the UAC prompt.","preventionTips":["Detect elevated context first and launch the helper directly without the runas verb","Refuse to attempt elevation in non-interactive sessions (services, CI) and report it","Verify the helper binary path exists before spawning; log the SE_ERR code on failure"],"tags":["windows","uac","elevation","etw","win32","rust"],"backgroundTag":"uac-elevation-failed","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}