Skip to content

Windows schtasks jobs fail with FILE NOT FOUND (bare opencode binary) #25

Description

@CENFARG

Description

Jobs scheduled via the schtasks (Windows) backend fail with FILE NOT FOUND because the task action invokes a bare opencode binary that Task Scheduler cannot resolve.

Environment

  • OS: Windows 10/11
  • Backend: schtasks
  • opencode installed via scoop (shim on user PATH)

Field evidence

  • Task action using bare opencode in schtasks /TR → Task Scheduler reports LastResult 2147942402 (0x80070002, FILE NOT FOUND); the plugin surfaces ENOENT -4058.
  • Scoop shims live in the interactive user PATH, which is invisible to the Task Scheduler session, so the bare name never resolves.
  • Same task rewritten with the absolute opencode binary path → LastResult 0, job runs.

Root cause

  • findOpencode() (src/index.ts:621) is POSIX-only (which/Unix candidate paths) and falls back to the bare opencode string on Windows.
  • The generated schtasks task sets no WorkingDirectory.
  • The schtasks backend has no stdout/stderr redirect to the scoped log (launchd/systemd backends have one), so the failure is silent unless you dig up LastResult.

Expected behavior

  • Resolve the absolute opencode binary on Windows (scoop shim dir, default install locations, where.exe).
  • Set WorkingDirectory on the schtasks task.
  • Redirect task output to the scoped log via a cmd wrapper, like the other backends.

A PR with the fix will reference this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions