2

I want the windows Task scheduler to run a *.bat File to run a python script.

Problem is, when I launch the *.bat File directly, I get Errorcode 0x1 in Task scheduler.

After searching I found that I need to set "Run with highest Privileges" on first page of Settings of the task, also I checked, that the user dont need to be logged in.

I also found the possible solution, that I should run the python.exe and should give Arguments the project-folder and start-in the main.py - but then I get the error-code 0x8007010B

I have a few other task schedulers running on the same pc with a similar python script - all of them work - the only difference is, that they don't log into a *.txt file.

has anyone experienced the same error?

EDIT:

I have changed the code and now getting the error 0x1 I see that last runtime is + 1 sec to planned starttime.

This is code of *.bat:

@echo off
python C:\scripts\CUSTOMERBIRTHDAY\main.py

When clicking direct executing - python script starts with no error. I have also tried to change "python" in script directly to python directory but also no solution.

With no @echo off there is no command window opened

Lukas Fürst
  • 81
  • 11
  • We have no real idea of what you're doing, so it's difficult to help. 0x8007010B is ERROR_DIRECTORY : "The directory name is invalid". Code is better than english to describe coding/dev issues https://stackoverflow.com/help/minimal-reproducible-example – Simon Mourier Jun 07 '23 at 09:51
  • 1
    @SimonMourier: Thanks for your answer - I have edited the quesiton info – Lukas Fürst Jun 07 '23 at 14:04
  • Have you tried running as a powershell script, rather than a bat file? Modern pwsh scripts should give more useful errors than cmd, which is the what bat files run in. – bob0the0mighty Jun 12 '23 at 14:15
  • https://superuser.com/questions/1641388/start-python-script-with-task-scheduler-via-powershell gives an overview of how to create a scheduled task with powershell as well. Note it bypasses the need for a bat file. If I remember correctly, it'll default to run as the user that created the scheduled task, but you should ensure that's correct. – bob0the0mighty Jun 12 '23 at 14:19
  • @bob0the0mighty thank you - now the command prompt opened when clicking right and run the program directly. It says that it can not open a file inside the python script – Lukas Fürst Jun 29 '23 at 10:48

0 Answers0