jdx/mise · error
`schtasks {}` failed: {printed}
Error message
`schtasks {}` failed: {printed} What it means
When applying enable/disable state changes to a scheduled task, the helper runs `schtasks /Change ...` and treats failure as fatal unless the exit code is SCHED_E_TASK_NOT_RUNNING or the printed output matches a known no-op error. Any other non-zero exit from schtasks surfaces as this error with the joined command and its output.
Source
Thrown at src/system/scheduled_tasks.rs:391
}
std::fs::write(&staging, &rendered)?;
if let Err(err) = schtasks(&create).await {
let _ = std::fs::remove_file(&staging);
return Err(err);
}
// written, not renamed: a rename does not replace an existing
// definition on Windows
std::fs::write(&path, &rendered)?;
let _ = std::fs::remove_file(&staging);
if end_first {
// it may have exited between the query and now: the HRESULT
// says so in every locale; the message is matched as a fallback
let (status, printed) = schtasks_output(&end).await?;
if !status.success()
&& status.code() != Some(SCHED_E_TASK_NOT_RUNNING)
&& !end_error_is_noop(&printed)
{
bail!("`schtasks {}` failed: {printed}", shell_words::join(&end));
}
}
if start {
schtasks(&run).await?;
}
}
Ok(())
}
/// Delete the task mise registered for `name`. Returns whether one existed.
pub(crate) async fn remove_task(name: &str, dry_run: bool) -> Result<bool> {
let task = task_name(name);
let path = definition_path(name);
if !exists(name).await? {
if path.exists() && !dry_run {
std::fs::remove_file(&path)?;
}
return Ok(false);View on GitHub (pinned to afd2eddd3a)
Solutions
- Read the `printed` output in the error: fix the underlying cause it reports (name mismatch, missing task, permissions).
- Run the operation elevated / as the correct user if output indicates access denied.
- If the task no longer exists, recreate or reinstall the service/task definition before changing its state.
- Verify the exact task name (including the 'mise\' folder prefix handling) matches the installed task.
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check the task exists and you have rights before changing state // schtasks /Query /TN "mise\\my-task" -> non-zero means fix name/permissions first
Try / catch
match apply_state_change(task) {
Err(e) if e.to_string().contains("schtasks") => {
log::error!("schtasks change failed: {e}; check task name, elevation, and task existence");
// inspect the embedded `printed` output for the OS-level reason before retrying
}
Err(e) => return Err(e),
Ok(v) => Ok(v),
} Prevention
- Run task state changes elevated or under the account that owns the task
- Confirm the task name (including the mise\\ prefix) before enabling/disabling/ending
- Treat SCHED_E_TASK_NOT_RUNNING as success for /End and handle it in your wrapper
- Re-create the task definition if schtasks reports corruption or missing task
When it happens
Trigger: Calling apply with start/stop (enable/disable or run/end) where schtasks_output returns a non-success status that is not the tolerated 'task not running' case — e.g. task name not found, access denied, or malformed task definition.
Common situations: Trying to end a task that is not running in a locale/message not covered by end_error_is_noop; insufficient privileges (service not run elevated); task deleted between check and change; corrupted task XML after a Windows update.
Related errors
- querying scheduled task {task} failed: {}
- could not find the suspended description command's primary t
- user service '{}': environment key {key:?} cannot be set thr
- scheduled task name {name:?} contains characters that cannot
- TEMP is too long to replace mise.exe safely ({len} UTF-16 co
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/563322a48aa4f4d0.
Report an issue: GitHub.