BigPizzaV3/CodexPlusPlus · error
ShellExecuteW returned
Error message
ShellExecuteW returned {code} What it means
open_url uses the Win32 ShellExecuteW API to open a URL/document; Windows reports success only when the return code is greater than 32. Any return value <= 32 (e.g. SE_ERR_NOASSOC, SE_ERR_ACCESSDENIED) is converted into this error showing the raw code.
Solutions
- Check the returned code: for 'no association' register or choose a handler (e.g. open with explicit 'cmd /c start' or a browser executable path)
- Ensure the process runs in an interactive user session with permission to launch shell items
- Validate the URL/file exists and uses a well-known scheme (http/https) before calling open_url; fall back to printing the URL for manual opening
Example fix
// before
open_url("myapp://deep-link")?;
// after
match open_url("myapp://deep-link") {
Ok(()) => {},
Err(e) => {
eprintln!("could not open automatically ({}); visit manually", e);
}
} Defensive patterns
Strategy: try-catch
Validate before calling
fn openable_target(url: &str) -> bool {
url::Url::parse(url).map(|u| matches!(u.scheme(), "http" | "https")).unwrap_or(false)
} Try / catch
match open_url(url) {
Err(e) => {
// Surface the ShellExecuteW code and fall back to clipboard/print
eprintln!("open failed: {e}; URL copied for manual open");
}
Ok(()) => {}
} Prevention
- Only open http/https URLs or files with known associations
- Keep default-browser associations healthy on target machines
- Run in an interactive session with shell-launch permissions
When it happens
Trigger: Calling open_url when the OS cannot open the target: no application associated with the URL/scheme, access denied, file not found, or out-of-resources errors returned by ShellExecuteW.
Common situations: Opening a custom URL scheme nobody handles; default-browser association broken on the machine; running in a restricted/service session where shell execution is denied; target file deleted between check and open.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- failed to open DevTools URL
- failed to wait for Windows process id
- SetThreadDpiAwarenessContext failed
- cannot terminate Windows process id
- Cannot verify launcher process identity
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/2a57c9dbb5dfd769.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/windows_integration.rs:173
}
#[cfg(windows)]
pub fn open_url(url: &str) -> anyhow::Result<()> {
let operation = wide_null("open");
let file = wide_null(url);
let result = unsafe {
ShellExecuteW(
None,
PCWSTR(operation.as_ptr()),
PCWSTR(file.as_ptr()),
PCWSTR::null(),
PCWSTR::null(),
SW_SHOWMINNOACTIVE,
)
};
let code = result.0 as isize;
if code <= 32 {
anyhow::bail!("ShellExecuteW returned {code}");
}
Ok(())
}
#[cfg(windows)]
pub fn set_current_user_string_value(subkey: &str, name: &str, value: &str) -> anyhow::Result<()> {
with_created_current_user_key(subkey, |key| {
let value = wide_null(value);
let bytes = slice_as_u8(&value);
unsafe {
RegSetValueExW(
key,
PCWSTR(wide_null(name).as_ptr()),
0,
REG_SZ,
Some(bytes),
)
}View on GitHub (pinned to b1ed92e5e4)