{"record":{"id":"5adfbd5da63a3aa2","repo":"ZyperWave/ZyperWinOptimize","slug":"optimize","errorCode":null,"errorMessage":"重启资源管理器失败: ","messagePattern":"重启资源管理器失败: ","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"ZyperWin++/ZyperWin++/Optimize.cs","lineNumber":2720,"sourceCode":"                        process.Kill();\r\n                        process.WaitForExit(5000);\r\n                    }\r\n                    catch\r\n                    {\r\n                        // 忽略无法终止的进程\r\n                    }\r\n                }\r\n\r\n                // 等待一段时间确保进程完全结束\r\n                System.Threading.Thread.Sleep(2000);\r\n\r\n                // 启动新的explorer进程\r\n                ProcessStartInfo startInfo = new ProcessStartInfo(\"explorer.exe\");\r\n\r\n            }\r\n            catch (Exception ex)\r\n            {\r\n                throw new Exception(\"重启资源管理器失败: \" + ex.Message);\r\n            }\r\n        }\r\n\r\n        // 保存配置到Config文件夹\r\n        private void SaveConfigToConfigFolder()\r\n        {\r\n            try\r\n            {\r\n                string ConfigFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, \"Config\");\r\n\r\n                // 确保Config文件夹存在\r\n                if (!Directory.Exists(ConfigFolder))\r\n                {\r\n                    Directory.CreateDirectory(ConfigFolder);\r\n                }\r\n\r\n                string fileName = $\"ZyperWin++{DateTime.Now:yyyyMMddHHmmss}.ini\";\r\n                string filePath = Path.Combine(ConfigFolder, fileName);\r","sourceCodeStart":2702,"sourceCodeEnd":2738,"githubUrl":"https://github.com/ZyperWave/ZyperWinOptimize/blob/d20e78bbd906fa179e4cc9f5107b502da5967aa9/ZyperWin++/ZyperWin++/Optimize.cs#L2702-L2738","documentation":"Optimize's restart-explorer routine kills explorer.exe and starts a fresh explorer.exe process; if any step in the try block throws (Process.Start failure, access issues), it rethrows as \"重启资源管理器失败: \" + ex.Message. It signals the shell could not be restarted, leaving the desktop without explorer.","triggerScenarios":"Calling the optimize/restore flow that restarts explorer when Process.Start(\"explorer.exe\") fails — explorer.exe missing from PATH/System32, win32 exception from process creation under restricted tokens, or the kill step failing with access denied.","commonSituations":"Running the tool from a service or non-interactive session where explorer cannot attach to the desktop; security software blocking new process creation; corrupted system files removing explorer.exe; running under a restricted account.","solutions":["Read ex.Message after the colon for the concrete Win32Exception (e.g. file not found vs access denied).","Verify C:\\Windows\\explorer.exe exists (sfc /scannow if missing).","Start explorer with an absolute path and UseShellExecute=true so it launches in the user's shell context.","Run the app as the interactive user (not as SYSTEM/service).","Fallback: let the user restart explorer manually via Task Manager if Process.Start fails."],"exampleFix":"// before\nProcessStartInfo startInfo = new ProcessStartInfo(\"explorer.exe\");\n// after\nProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), \"explorer.exe\")) { UseShellExecute = true };\n// plus a catch that notifies instead of throwing away the shell\ncatch (Exception ex) { MessageBox.Show(\"重启资源管理器失败: \" + ex.Message + \"\\n请手动重启 explorer.exe\"); }","handlingStrategy":"try-catch","validationCode":"string explorerPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), \"explorer.exe\");\nif (!File.Exists(explorerPath)) { MessageBox.Show(\"explorer.exe 缺失，跳过重启\"); return; }","typeGuard":null,"tryCatchPattern":"try { RestartExplorer(); }\ncatch (Exception ex)\n{ MessageBox.Show($\"重启资源管理器失败: {ex.Message}\\n可手动在任务管理器重启 explorer.exe。\", \"错误\", MessageBoxButtons.OK, MessageBoxIcon.Warning); /* continue without aborting the whole flow */ }","preventionTips":["Use an absolute path to explorer.exe with UseShellExecute=true.","Treat explorer restart as best-effort; never let it abort the optimization result.","Don't run the tool as a service/SYSTEM account.","Verify system integrity (sfc /scannow) if explorer.exe is repeatedly missing."],"tags":["process-start","explorer","windows","shell-restart"],"backgroundTag":"process-start-failed","analyzedSha":"d20e78bbd906fa179e4cc9f5107b502da5967aa9","analyzedAt":"2026-09-13T15:15:37.168Z","contentChangedAt":"2026-09-13T15:15:37.168Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}