OdysseusYuan/LKY_OfficeTools · error · Exception
执行 {file_path} 异常!
Error message
执行 {file_path} 异常! What it means
Thrown by Com_ExeOS.Run.Exe when its private Process() helper returns false, meaning Process.Start() raised a Win32Exception while trying to launch file_path (Com_ExeOS.cs:24). The exception is caught inside Exe itself, logged via Lib_AppLog, and the method returns the sentinel -920921 (Com_ExeOS.cs:37), so callers observe failure as a return value, not a propagating throw. The interpolated file_path identifies exactly which executable failed to start.
Source
Thrown at LKY_OfficeTools/Common/Com_ExeOS.cs:29
using static LKY_OfficeTools.Lib.Lib_AppLog;
namespace LKY_OfficeTools.Common
{
internal class Com_ExeOS
{
internal class Run
{
internal static int Exe(string file_path, string args)
{
try
{
Process p = new Process();
var result = Process(file_path, args, out p, true); //默认等待完成
//是否执行了
if (!result)
{
throw new Exception($"执行 {file_path} 异常!");
}
return p.ExitCode;
}
catch (Exception Ex)
{
new Log(Ex.ToString());
return -920921;
}
}
internal static bool Process(string file_path, string args, out Process ProcessInfo, bool WaitForExit)
{
try
{
Console.ForegroundColor = ConsoleColor.Gray;
ProcessInfo = new Process();View on GitHub (pinned to 6f9a1bd471)
Solutions
- Before calling, verify the target with File.Exists(file_path) and confirm it is a real executable.
- Normalize the path with Path.GetFullPath and ensure it is quoted/escaped correctly for the shell context.
- Match the executable's bitness to the host process (or force x86/x96 via the project's Platform target).
- Reproduce by launching the same file_path from cmd.exe to read the underlying Win32 error code.
- If the target needs elevation, run the host process elevated or use ProcessStartInfo.Verb = "runas".
Example fix
// before
int code = Com_ExeOS.Run.Exe(toolPath, args);
// after
if (!System.IO.File.Exists(toolPath)) { /* report missing tool, abort */ return; }
int code = Com_ExeOS.Run.Exe(toolPath, args);
if (code == -920921) { /* launch failed; details already written to log */ } Defensive patterns
Strategy: validation
Validate before calling
const int RUN_FAILED = -920921;
if (!File.Exists(file_path)) { /* report missing tool */ return; }
int code = Com_ExeOS.Run.Exe(file_path, args);
if (code == RUN_FAILED) { /* launch failed; details in Lib_AppLog */ } Type guard
static bool CanLaunch(string path) => !string.IsNullOrWhiteSpace(path) && File.Exists(path);
Prevention
- Always normalize and verify file_path with Path.GetFullPath + File.Exists before launching.
- Treat the -920921 sentinel from Run.Exe as a hard launch failure and surface it to the operator.
- Match the executable bitness to the host process to avoid Win32 start errors.
- Keep bundled helper binaries copied next to the assembly as part of the build/deploy step.
When it happens
Trigger: Calling Run.Exe(path, args) where path does not exist, is not a valid PE executable, has missing native DLL dependencies, the wrong bitness for the host, or is blocked by AppLocker/SmartScreen/antivirus. Also when UseShellExecute=false and the account lacks execute permission on the file.
Common situations: A bundled helper binary was not copied next to the assembly on deploy; a path containing spaces was passed unquoted; a 32-bit-only tool launched on ARM64 without emulation; antivirus quarantined the exe after a signature update.
AI-assisted analysis of OdysseusYuan/LKY_OfficeTools@6f9a1bd471 (2026-08-13).
Data as JSON: /api/errors/0686e99037728408.
Report an issue: GitHub.