{"record":{"id":"b73d5e96405f3c77","repo":"coreybutler/nvm-windows","slug":"unscheduling-error-v-s","errorCode":null,"errorMessage":"unscheduling error: %v\n%s","messagePattern":"unscheduling error: (.+?)\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/upgrade/register.go","lineNumber":207,"sourceCode":"schtasks /delete /tn \"%s\" /f > %%output%% 2>&1\nif not errorlevel 0 (\n\techo failed to remove scheduled task: exit code: %%errorlevel%% >> %%errorlog%%\n\ttype %%output%% >> %%errorlog%%\n\texit /b %%errorlevel%%\n)\n\t`, tmp, name)\n\n\terr = os.WriteFile(filepath.Join(tmp, \"unschedule.bat\"), []byte(script), os.ModePerm)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unscheduling error: %v\", err)\n\t}\n\n\tcmd := exec.Command(filepath.Join(tmp, \"unschedule.bat\"))\n\n\t// Capture standard output and standard error\n\tout, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unscheduling error: %v\\n%s\", err, out)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":189,"sourceCodeEnd":212,"githubUrl":"https://github.com/coreybutler/nvm-windows/blob/5b18223ca19ff50d707f35410dbc6bd440a9f74d/src/upgrade/register.go#L189-L212","documentation":"UnscheduleTask() executed unschedule.bat (schtasks /delete /tn <name> /f) and the script exited non-zero; the error embeds the process error plus schtasks' combined output. In practice the embedded batch's own `if not errorlevel 0` logic is inverted (errorlevel 0 means success), so this can also fire spuriously even when deletion succeeded.","triggerScenarios":"schtasks /delete failing: task does not exist (already removed), access denied without elevation, or corrupt task registration. Also fires spuriously because the generated batch treats errorlevel 0 (success) as failure.","commonSituations":"Running an upgrade twice (task already deleted the first time); non-elevated shell removing a task registered by an elevated context; the batch errorlevel-logic bug turning every successful deletion into an error.","solutions":["Check whether the task actually still exists: schtasks /query /tn <taskname> — if it is gone, the error is the known false positive and can be ignored","Run the nvm operation from an elevated terminal so /delete has rights","Delete manually: schtasks /delete /tn <taskname> /f"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := UnscheduleTask(name); err != nil {\n    // verify actual state: the generated batch misreads errorlevel, success can report as failure\n    if qerr := exec.Command(\"schtasks\", \"/query\", \"/tn\", name).Run(); qerr != nil {\n        log.Printf(\"task %s still present: %v\", name, err) // genuine failure\n    } else {\n        // task is gone; treat error as the known false positive\n    }\n}","preventionTips":["After unscheduling, verify with `schtasks /query /tn <name>` instead of trusting the exit error","Be aware the generated batch's `if not errorlevel 0` logic is inverted","Run elevated to avoid genuine access-denied deletions"],"tags":["nvm-windows","schtasks","scheduled-tasks","windows","false-positive"],"backgroundTag":null,"analyzedSha":"5b18223ca19ff50d707f35410dbc6bd440a9f74d","analyzedAt":"2026-08-15T10:06:51.428Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}