{"record":{"id":"d250c20e92a72e3a","repo":"BigPizzaV3/CodexPlusPlus","slug":"windows","errorCode":null,"errorMessage":"无法定位 Windows 启动目录","messagePattern":"无法定位 Windows 启动目录","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/watcher.rs","lineNumber":859,"sourceCode":"            if !remaining.is_empty() {\n                let _ = crate::diagnostic_log::append_diagnostic_log(\n                    \"watcher.stop_wait_timeout\",\n                    serde_json::json!({\n                        \"remaining_process_ids\": remaining,\n                        \"timeout_ms\": timeout_ms\n                    }),\n                );\n            }\n            break;\n        }\n        std::thread::sleep(Duration::from_millis(interval_ms));\n    }\n}\n\n#[cfg(windows)]\nfn create_startup_shortcut(launcher_path: &Path, arguments: &str) -> anyhow::Result<()> {\n    let Some(shortcut_path) = startup_shortcut_path() else {\n        anyhow::bail!(\"无法定位 Windows 启动目录\")\n    };\n    crate::windows_integration::create_shortcut(&crate::windows_integration::ShortcutSpec {\n        path: shortcut_path,\n        target: launcher_path.to_path_buf(),\n        arguments: arguments.to_string(),\n        working_directory: launcher_path.parent().map(Path::to_path_buf),\n        description: \"Codex++ watcher\".to_string(),\n        icon: None,\n        show_minimized: true,\n    })\n}\n\n#[cfg(windows)]\nfn spawn_launcher(launcher_path: &Path, debug_port: u16) {\n    let command = build_spawn_launcher_command(&launcher_path.to_string_lossy(), debug_port);\n    if let Some((exe, args)) = command.split_first() {\n        let mut command = Command::new(exe);\n        command","sourceCodeStart":841,"sourceCodeEnd":877,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/watcher.rs#L841-L877","documentation":"On Windows, create_startup_shortcut needs the user's Startup folder (via startup_shortcut_path(), typically SHGetKnownFolderPath FOLDERID_Startup). When that path cannot be determined, installing the watcher shortcut fails with this Chinese-language error meaning 'cannot locate the Windows startup directory'.","triggerScenarios":"Calling install_watcher on Windows when startup_shortcut_path() returns None — the known-folder API fails, e.g. a corrupted/redirected user profile, service account without a user profile, or restricted environment.","commonSituations":"Running under a service or scheduled context with no interactive user profile; heavily customized/roaming profile where the Startup folder is unavailable; restricted corporate images.","solutions":["Ensure the process runs as a normal interactive user whose profile (and Startup folder) exists; avoid running the installer as a service or SYSTEM","Manually create the shortcut in the Startup folder ('shell:startup') pointing at the launcher, then skip programmatic install","Check the Windows user profile integrity; for redirected profiles verify the known-folder registration in the registry"],"exampleFix":"// before\nwatcher::install_watcher(&launcher, 9222)?;\n// after\nmatch watcher::install_watcher(&launcher, 9222) {\n    Ok(()) => {},\n    Err(e) if e.to_string().contains(\"启动目录\") => {\n        eprintln!(\"autostart unavailable; create a shortcut in shell:startup manually\");\n    }\n    Err(e) => return Err(e),\n}","handlingStrategy":"fallback","validationCode":"// precheck: Startup folder must resolve\nif dirs::document_dir().is_none() || std::env::var(\"USERPROFILE\").is_err() {\n    eprintln!(\"no user profile; autostart shortcut unavailable\");\n}","typeGuard":null,"tryCatchPattern":"match watcher::install_watcher(&launcher, port) {\n    Err(e) if e.to_string().contains(\"启动目录\") => {\n        eprintln!(\"create the shortcut manually in shell:startup\");\n    }\n    other => other?,\n}","preventionTips":["Run install under an interactive user account, not as a service/SYSTEM","Avoid installer contexts without a loaded user profile","Offer manual 'shell:startup' instructions as a documented fallback"],"tags":["windows","filesystem","startup-folder"],"backgroundTag":"directory-not-found","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}