jdx/mise · error
querying scheduled task
Error message
querying scheduled task {task} failed: {} What it means
After running the schtasks query, mise checks the exit status; a non-zero status makes mise surface schtasks' stderr verbatim as this error. It wraps the underlying Windows Task Scheduler failure — typically 'the system cannot find the file specified' when the task does not exist, or access/timeout problems.
Solutions
- Check the embedded stderr message: if it says the task does not exist, run the task's apply/create first or treat 'not found' as expected
- Run the terminal elevated (or as the same user that created the task) if access was denied
- Verify the Task Scheduler service is running and retry; note the separate timeout error exists for hangs
- Run `schtasks /query /tn <name>` manually to reproduce and see the raw error
Example fix
// before
let running = task_exists("Mise\\deploy-hook").await?;
// after
let running = match task_exists("Mise\\deploy-hook").await {
Ok(v) => v,
Err(e) if e.to_string().contains("cannot find") => false,
Err(e) => return Err(e),
}; Defensive patterns
Strategy: try-catch
Try / catch
match mise_scheduled_task_status(name) {
Ok(status) => status,
Err(e) if e.to_string().to_lowercase().contains("cannot find") => Status::Missing,
Err(e) => return Err(e),
} Prevention
- Treat 'task not found' stderr as an expected state, not a hard failure
- Ensure the same user/elevation level created and queries the task
- Run apply before querying newly configured tasks
- Verify the Task Scheduler service is healthy on the machine
When it happens
Trigger: query() in scheduled_tasks.rs runs schtasks and the process exits non-zero: the task name does not exist, the user lacks permission to read the task, the Task Scheduler service is unavailable, or the command printed an error to stderr.
Common situations: Checking status of a scheduled task before it was ever created (apply never ran), running without the privileges needed to read tasks in another folder or created by another user, or schtasks failing due to a transient system condition.
Related errors
- `schtasks ` failed
- scheduled task name contains characters that cannot be…
- user service ' ': environment key cannot be set through…
- user service ' ': the command contains , which cmd.exe…
- watch_files command failed
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/ba9512ba5dcbd19f.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/scheduled_tasks.rs:492
}
let args = [
"-NoProfile".to_string(),
"-NonInteractive".to_string(),
"-Command".to_string(),
query_script(name),
];
debug!("$ powershell {}", shell_words::join(&args));
let mut cmd = tokio::process::Command::new("powershell.exe");
cmd.args(&args)
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.kill_on_drop(true);
let output = tokio::time::timeout(SCHTASKS_TIMEOUT, cmd.output())
.await
.map_err(|_| eyre!("querying scheduled task {task} timed out"))??;
if !output.status.success() {
bail!(
"querying scheduled task {task} failed: {}",
String::from_utf8_lossy(&output.stderr).trim()
);
}
Ok(parse_query(&String::from_utf8_lossy(&output.stdout)))
}
fn parse_query(output: &str) -> Option<Query> {
let state = output.trim();
if state.eq_ignore_ascii_case("MISSING") || state.is_empty() {
return None;
}
Some(Query {
running: state.eq_ignore_ascii_case("Running"),
disabled: state.eq_ignore_ascii_case("Disabled"),
})
}
View on GitHub (pinned to 533346cc37)