babalae/better-genshin-impact · warning · ArgumentException
当前只允许选择 .exe 程序。
Error message
当前只允许选择 .exe 程序。
What it means
Thrown by ValidateExecutablePath when the selected file's extension is not ".exe" (case-insensitive). The Task Scheduler exec action used for elevated Child Session launch requires a real executable; scripts and shortcuts are rejected to avoid ambiguous behavior.
Source
Thrown at BetterGenshinImpact/Service/ChildSession/ChildSessionProcessLauncher.cs:208
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))
{
Marshal.FinalReleaseComObject(value);
}
}
View on GitHub (pinned to a7cb36712d)
Solutions
- Select a .exe file directly.
- To run a script, launch cmd.exe or powershell.exe as the executable and pass the script path as an argument.
- Convert the script into a packaged executable if frequent launches are needed.
Defensive patterns
Strategy: validation
Validate before calling
var fullPath = Path.GetFullPath(executablePath);
if (!string.Equals(Path.GetExtension(fullPath), ".exe", StringComparison.OrdinalIgnoreCase))
{
throw new ArgumentException("当前只允许选择 .exe 程序。", nameof(executablePath));
} Try / catch
try
{
await launcher.LaunchElevatedAsync(childSessionId, exePath);
}
catch (ArgumentException ex) when (ex.Message.Contains(".exe"))
{
logger.LogWarning("Only .exe files are allowed for Child Session launch");
} Prevention
- Filter the file picker to *.exe so users cannot select other extensions.
- Document that scripts must be wrapped (cmd.exe/powershell.exe as the executable) in the launch UI.
- Validate the extension before dispatching to the Task Scheduler path.
When it happens
Trigger: User selects a .bat, .cmd, .ps1, .lnk, .msi, or a file with no extension via LaunchExecutableAsync.
Common situations: User tries to launch a batch file or PowerShell script directly into the Child Session; user picks a Start Menu shortcut (.lnk).
Related errors
- 要启动的程序不存在。
- manifest.json: name is required.
- manifest.json: version is required.
- manifest.json: main script is required.
- 文件路径不能为空
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/867e307f6efd6c2b.
Report an issue: GitHub.