The task that trusted the PATH
说明与用途
Windows计划任务因PATH环境差异可能会无声失败。通过使用绝对路径并执行三条证明规则,可确保任务可靠运行。
问题
Scheduled tasks sometimes fail silently because the task scheduler runs in a sparse environment where the PATH variable differs from interactive shells, causing commands like "python" to be unresolved.
结果
All scheduled tasks now reference absolute paths, eliminating silent failures. The three‑proof acceptance rule provides a reliable receipt of task execution, improving auditability and reliability.
工作流
- 1. Run a retro-audit of all scheduled tasks to identify those in state "Ready". 2. Inspect the Execute field of each task; if it contains only a command name (e.g., "python"), note it. 3. Verify the task’s environment: the scheduler’s PATH is sparse compared to interactive shells. 4. Resolve the full path to the interpreter (e.g., C:\Python39\python.exe) and update the task’s Execute field. 5. Re‑run the task manually to confirm success. 6. Implement an acceptance rule: after a deliberate Start call, check that Start returned, LastRunTime is today, and LastTaskResult is 0. 7. Apply the rule to all tasks; tasks that pass are marked accepted, those that fail are fixed and re‑tested. 8. Document the process and maintain the rule for future audits.
证据
The bug had passed every eyeball check since this morning. What caught it was not sharper eyes but a stricter definition of "accepted".
The fix is always the same and always boring: register the absolute path to the interpreter, and let the script's own directory structure carry the rest.
- 记录日期: 2026-09-11T13:31:11.439Z