0

Hi folks so I got the following problem,

I have the following code in a batch file: ..\python-2.7.10.amd64\python.exe ./bin/bla.py ./conf/config.conf > ./logs/output.txt

This works like a charme by double clicking the batch. Next my plan was to automate the call of this batch by adding it to the task scheduler in windows. So I changed all the relative paths to absolute paths:

D:\path\to\python-2.7.10.amd64\python.exe D:\path\to\bin\bla.py D:\path\to\conf\config.conf > D:\path\to\logs\output.txt

This also still works by double clicking the batch file.

So my next step was adding the batch to the task scheduler but when I run it from there I get this error message:

Traceback (most recent call last): File "D:\path\to\bin\bla.py", line 159, in logging.config.fileConfig(logFile) File "D:\path\to\python-2.7.10.amd64\lib\logging\confi eConfig formatters = _create_formatters(cp) File "D:\path\to\python-2.7.10.amd64\lib\logging\confi reate_formatters flist = cp.get("formatters", "keys") File "D:\path\to\python-2.7.10.amd64\lib\ConfigParser. raise NoSectionError(section) ConfigParser.NoSectionError: No section: 'formatters'

So for some reason the python script can't find the conf file by the absolute path I think but I don't understand why. I also tried it with the relative paths in the task scheduler it obviously also doesn't work.

Does anyone of you have a clue why it works straight from the batch but not from the task scheduler ?

niCon
  • 1
  • 3
  • Did you set the working directory in the scheduled task to the location of the batch file? – Jason Faulkner Dec 10 '15 at 14:47
  • It's hard to tell since we can't see your python script code. Try to add the script and an explanation on how you set up the task in the task scheduler. It might be an issue with permissions since task scheduler can run as System and not as user. Another thing, try adding the command: cd "", that might help since running batch files with task scheduler automatically starts in the User folder/System folder(system32 folder) – equinox93 Dec 10 '15 at 15:38
  • Anything special about "D:"? Is it a network share or a SUBST? What about environment variables (especially PATH)? Programs run from the TaskScheduler are run in a different session and often under a different user account. Drive letter assignments can be different. Typically, hard drives won't be different, but network shares and SUBST are usually local to your login session. Hmmm, since the script seems to have started, "D" must be normal enough. – joeking Dec 10 '15 at 17:10

1 Answers1

0

Thank you guys for your help. It was indeed "just" the working directory I had to set to the location of the bat file

niCon
  • 1
  • 3