Jump to content

problem downloading files using task scheduler


Recommended Posts

hi,

I'm new using autoit, I'm just using this tool to download some reports every 30 minutes,  this I what I have:

#include <IE.au3>

Call ("SignIn")


Func SignIn ()
Global $oIE = _IECreate ("http://url.com")

Local $username = _IEGetObjByName($oIE, "username")
Local $password = _IEGetObjByName($oIE, "password")
Local $button = _IEGetObjByName($oIE, "submitFrmShared")

_IEFormElementSetValue ($username,"administrator")
_IEFormElementSetValue ($password,"Pa55word")

_IEAction ( $button, "click")
Call ("copytext")
EndFunc

Func copytext ()
WinWait('File Download')
WinActivate('File Download')
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{Enter}")
WinWait('Save As')
WinActivate('Save As')
Send("C:\reporttest.csv")
Send("{Enter}")
Sleep(10000)

RunWait('taskkill /F /IM "iexplore.exe"')
EndFunc

Basically I access to the report url using my credentials, then I start the download and use the keyboard to save the file on the disk C: .

If I click on the generated .exe the script works fine and downloads the report but if I use the task scheduler and configured a task to run the exe whether user is logged on or not, nothing happens( if I use the option run only when user is logged on runs perfectly but that's not the option I'm looking for), the problem is I see internet explorer process running on the windows task manager but the task on the task scheduler never ends but I'm not sure what could be the problem, any possible solution to this? I read about InetGet and I made a test but didn't work, not sure if the problem is I start with an authentication before I download the reports.

Any help would be appreciated,

Thanks and regards, Sergio. 

 

Edited by Jos
Added codebox
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...