Reputation: 31
I am trying to run script (script1.py
) from windows task scheduler
. The script is supposed to control Chrome webdriver
and I believe it could be the root of the problem.
Result is 0x1.
Before creating the task I tested the execution of script1.py
directly from cmd
and it works.
So I've created script which writes into the file in the same location as script1.py
, than created task - 0x0
, record is added to the file.
works:
<Exec>
<Command>C:\Windows\System32\cmd.exe</Command>
<Arguments>/c C:\Users\MyUser\Anaconda3\python.exe d:\folder\write_dummy_file.py</Arguments>
</Exec>
Doesn't work:
<Exec>
<Command>C:\Windows\System32\cmd.exe</Command>
<Arguments>/c C:\Users\MyUser\Anaconda3\python.exe d:\folder\script1.py</Arguments>
</Exec>
The task to run write_dummy_file.py
was created from xml
file of the task to run script1.py
.
Those are modules used in the problem script1
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from datetime import datetime
import time
import win32com.client as comclt
import pickledb
In the logs I see "Action started", "Action completed", "Task completed". In the Task Manager I can see multiple instances of the Chromedriver, but expected job is not done - browser was never opened.
Upvotes: 2
Views: 4992
Reputation: 91
I had the same problem, but I searched all kinds of ways on Google that were unsuccessful. Finally, I found that the reason for the execution failure was that my py script had a third-party library that was not installed in Python (the script worked well in spyder, but "DLL load failed" in python.exe)hoping to help people in similar situations
Upvotes: 0
Reputation: 31
Since we deal with webdriver in the script, the execution should be visible. Task has to be set for "Run only when user is logged in", otherwise it ran in background and failed (it was set to "Run whether user is logged on or not").
Upvotes: 1