0

So I have a server which runs on windows system, and I need to schedule a daily task with windows task scheduler for a batch file which executes a python script which contains selenium operation (I am using a chrome driver), the expected outcome is to automatically download a file from online and then unzipped it to another folder. i.e. Program download the file and stored it in C:\download then unzipped it to E:\Data.

Everything is working fine if I set "Run only when user is logged on" in windows scheduler or I just ran the program manually. However, when I set "Run whether user is logged on or not", I won't see any file gets downloaded, so I suspect in order to let it work, one must log on to get webdriver interacts with website? I have refer to this site and seems like it is the case though the author is using edge (https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/7290550/). Can anyone help to confirm this or can someone offer me a solution?

Moreover, if I manually leave the zipped file in i.e. C:\download, when the task starts with "Run whether user is logged on or not", I can see the file gets unzipped in the destination folder i.e. E:\Data which means part of my script (the extract part) is executed. So I am positive the task started successfully, but there's just no interaction in between selenium and website. Thanks.

P.S. My script does not contain any mapped driver, so this solution doesn't apply (https://social.technet.microsoft.com/Forums/windows/en-US/c03d6691-b058-4f8d-961c-e8eba25bbaed/task-scheduler-problem-run-whether-user-is-logged-on-or-not?forum=w7itprogeneral), and neither does this help (Task scheduler cannot open batch file when set to run whether user is logged on or not).

Gin
  • 129
  • 2
  • 12
  • 1
    when running from task scheduler, initial path is system directory. also, check user permissions, local service account may have not enough privileges to run certain programs or access certain folders/files. you may run your task under some user account with enough privileges. more also, gui applications may not run if user is logged off – elzooilogico Apr 10 '19 at 18:36
  • I have administrator privileges for the server, so I shall be good for that part. I think the last sentence you mentioned 'gui applications may not run if user is logged off' coincide with my suspicion as I saw part of the scripted got executed but not the part where the program needs to open and interact with the browser. Thanks. – Gin Apr 10 '19 at 18:44
  • Programs set other than run when user logged in are INVISIBLE. – Noodles Apr 11 '19 at 07:34
  • Yep, I know the program is INVISIBLE, but the program just finishes with part of my code, as nothing gets downloaded to the destination folder... So that's why I am highly suspected when run without logged in, web interactions can not be enabled. – Gin Apr 13 '19 at 16:28

0 Answers0