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!