fix(daemon): accept 'Last Result' schtasks key variant on Windows (#47726)

Some Windows locales/versions emit 'Last Result' instead of 'Last Run Result' in schtasks output, causing gateway status to falsely report 'Runtime: unknown'. Fall back to the shorter key when the canonical key is absent.
This commit is contained in:
MoerAI
2026-03-16 12:11:58 +09:00
committed by Peter Steinberger
parent 69c12c2b11
commit 3e8bc9f16a
2 changed files with 17 additions and 1 deletions

View File

@@ -23,6 +23,20 @@ describe("schtasks runtime parsing", () => {
lastRunResult: "0x0",
});
});
it("parses 'Last Result' key variant (without 'Run') (#47726)", () => {
const output = [
"TaskName: \\OpenClaw Gateway",
"Status: Running",
"Last Run Time: 2026/3/16 8:34:15",
"Last Result: 267009",
].join("\r\n");
expect(parseSchtasksQuery(output)).toEqual({
status: "Running",
lastRunTime: "2026/3/16 8:34:15",
lastRunResult: "267009",
});
});
});
describe("scheduled task runtime derivation", () => {

View File

@@ -178,7 +178,9 @@ export function parseSchtasksQuery(output: string): ScheduledTaskInfo {
if (lastRunTime) {
info.lastRunTime = lastRunTime;
}
const lastRunResult = entries["last run result"];
// Some Windows locales/versions emit "Last Result" instead of "Last Run Result".
// Accept both so gateway status is not falsely reported as "unknown" (#47726).
const lastRunResult = entries["last run result"] ?? entries["last result"];
if (lastRunResult) {
info.lastRunResult = lastRunResult;
}