Windows Task scheduler job runs manually but fails when scheduled with return code 2147942401.

William Jacobs 20 Reputation points
2026-10-06T17:35:48.2566667+00:00

I have a Windows Tsk scheduler job that runs a batch file that executes a python program to pull a file down from a snowflake database. Then I execute the task manually it runs fine. When I schedule it to run, it says it ran sucessfully, but no file is downloaded. In the task log I get a return code of 2147942401 instead of the 0 I get when I run it manually,

Windows for business | Windows Server | User experience | Other
0 comments No comments

Answer accepted by question author
Chen Tran 13,435 Reputation points Independent Advisor
2026-10-06T18:03:13.3333333+00:00

Hello William,

Thank you for posting question on Microsoft Windows Forum!Based on the issue description as well as the provided error code 2147942401 or "Incorrect function" which typically occurs in Windows Task Scheduler when a script works interactively but fails as a scheduled task because the scheduled execution environment differs significantly from your interactive session.

When Task Scheduler runs a task, the default working directory is C:\Windows\System32, not the folder containing your batch file or Python script. If your Python script uses relative paths, the file is either written to System32 (where you lack permission) or fails silently. The suggestion here is in the Task's Action tab, set the "Start in (optional)" field to the directory containing your batch file and Python script.

Alternatively, you can open your batch file and update it to use full absolute paths for both the Python executable (e.g., C:\Program Files\Python311\python.exe instead of python) and your script (e.g., C:\Scripts\pull_snowflake.py). Scheduled tasks run in a stripped-down environment that often cannot resolve local user environment paths.

I hope you have found something useful here. If it helps you get more insight into the issue, it is appreciated to accept the answer. Should you have more questions, feel free to leave a message. Have a nice day!

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.