babalae/better-genshin-impact · error · FileNotFoundException
要启动的程序不存在。
Error message
要启动的程序不存在。
What it means
Thrown by ValidateExecutablePath when File.Exists returns false for the resolved full path. The FileNotFoundException carries the path as fileName so the caller can see which file was missing.
Source
Thrown at BetterGenshinImpact/Service/ChildSession/ChildSessionProcessLauncher.cs:203
// 临时任务启动成功后,清理失败不应中断已经启动的目标程序。
}
}
ReleaseComObject(runningTaskObject);
ReleaseComObject(registeredTaskObject);
ReleaseComObject(actionObject);
ReleaseComObject(taskDefinitionObject);
ReleaseComObject(rootFolderObject);
ReleaseComObject(schedulerObject);
}
}
private static string ValidateExecutablePath(string executablePath)
{
var fullPath = Path.GetFullPath(executablePath);
if (!File.Exists(fullPath))
{
throw new FileNotFoundException("要启动的程序不存在。", fullPath);
}
if (!string.Equals(Path.GetExtension(fullPath), ".exe", StringComparison.OrdinalIgnoreCase))
{
throw new ArgumentException("当前只允许选择 .exe 程序。", nameof(executablePath));
}
return fullPath;
}
private static string QuoteArgument(string argument)
{
return $"\"{argument.Replace("\"", "\\\"", StringComparison.Ordinal)}\"";
}
private static void ReleaseComObject(object? value)
{
if (value is not null && Marshal.IsComObject(value))View on GitHub (pinned to a7cb36712d)
Solutions
- Verify the executable exists at the given absolute path before invoking launch.
- Re-select the executable file in the UI to capture a fresh path.
- Use a local absolute path rather than a network/removable location.
Defensive patterns
Strategy: validation
Validate before calling
var fullPath = Path.GetFullPath(executablePath);
if (!File.Exists(fullPath))
{
throw new FileNotFoundException("要启动的程序不存在。", fullPath);
} Try / catch
try
{
await ChildSessionProcessLauncher.LaunchElevatedAsync(childSessionId, exePath);
}
catch (FileNotFoundException ex)
{
logger.LogError(ex, "Executable not found: {FileName}", ex.FileName);
} Prevention
- Capture the executable path at launch time rather than caching a stale selection.
- Prefer local absolute paths over network/removable locations.
- Validate File.Exists in the UI before enabling the launch button.
When it happens
Trigger: LaunchElevatedAsync(childSessionId, executablePath) is called with a path whose target was deleted, moved, or never existed; the path is on a network share that is currently disconnected; the path contains an unexpanded variable or relative segment that resolves to a non-existent location.
Common situations: User selected an executable earlier, then moved/deleted it; executable lives on a removable drive that was ejected; path was typed manually with a typo; UNC path to an offline share.
Related errors
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/99be0585831592ab.
Report an issue: GitHub.