neilontherock Posted January 26, 2009 Posted January 26, 2009 Hi, I have perl script written that starts an Internet Explorer session, navigates to a website and downloads a file using the Autoit ActiveX Control. It works great. The problem I am having is when I move this script to our server and create a scheduled task to run the script it does work (it runs as Admin). I am logged into the machine via Remote Desktop, I wait for the scheduled task to start but it does bring up Internet Explorer and the file does not download. If I try the same thing on my local PC it works fine. If I run the script manually on the Remote Desktop machine it brings up Internet Explorer and works as excepted. Does anyone know why the script would not bring up the Internet Explorer Window on the Remote Machine or what I can do to get this to work? Any help would be greatly appreciated.
zfisherdrums Posted January 26, 2009 Posted January 26, 2009 (edited) Hello, The language in your question is slightly murky. Which is correct? [A] The problem is that it DOES work when run as a scheduled task on the server? The problem is that it DOES NOT work when run as a scheduled task on the server? If the answer is , I have had similar problems. I believe the problem stems from the fact that when an app is running "underneath" a locked session, the OS blocks all window related operations for security purposes. If your script is dependent upon waiting for a dialog to appear (e.g., "Save As..."), then then any WinXXXXX commands will fail. We had this problem when we would start scripts on while logged in, then logged off mid-way through the script. We would return later to discover the script halted on a WinXXXX command. One workaround is to attempt to download the file using libraries and methods that are germane to perl. For example, downloaded the page, scraping the source for the link, download direct from found link. This would require no window interactions. I hope this helped. If it hasn't, let us know what else makes your issue unique. Zach fisher... Edited January 26, 2009 by zfisherdrums Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog...
herewasplato Posted January 26, 2009 Posted January 26, 2009 (edited) ... then then any WinXXXXX commands will fail ...That should not be the case. Some of the WinXXXX commands should work while the workstation is locked. As mentioned in this FAQ post: http://www.autoitscript.com/forum/index.ph...st&p=571221 ... So generally don't use Send() MouseClick() WinActivate() WinWaitActive() WinActive() etc. Instead use ControlSend() ControlSetText() ControlClick() WinWait() WinExists() WinMenuSelectItem() etc. ... Assuming that the OP is still using code that is close to what was posted here: http://www.autoitscript.com/forum/index.ph...showtopic=88115 It should work under a locked session. It has been a while since I checked that those listed functions all work when the computer is locked - but I do not think that this has changed. Maybe they can be of help in some future code. @neilontherock, It seems that you first posted in the General Help and Support forum You got some good help and a suggestion to post in the AutoItX forum Two threads of yours go unanswered in the AutoItX forum (It appears that you solved those issues yourself.) You posted back to the General Help and Support forum with this thread. (Which is fine given that the issue is probably not AutoItX related per se.) I chronicle that history as a testament to your patience and thank you for same. I've repeated your OP in a way: move this script to our server create a scheduled task to run the script it does work (it runs as Admin). login via Remote Desktop wait for the scheduled task to start it does [not] bring up Internet Explorer the file does not download Based on your restatement of the problem: "Does anyone know why the script would not bring up the Internet Explorer Window on the Remote Machine ...", I added only one [not] to the restatement above. If the script does not work as expected as a scheduled task when you are not connected via Remote Desktop - then maybe you have changed the code from what you originally posted and have used one of those AutoIt functions that the FAQ mentions will not work on a locked workstation. If the script does work on the server when you are when you are not connected via Remote Desktop - then follow the advice given in that old joke: Patient: Doctor, Doctor, it hurts when I do this. Doctor: Then don't do that. Seriously, if the [script] only fails when you are connected via Remote Desktop - then test using a different remote tool like ShowMyPC. It is a single file (nothing to install) that uses SSH/TightVNC as a remote control tool. See if the issue is related to Remote Desktop. My stating that I am not a knot head is not using a double negative since the two negatives are in different clauses. It is grammatically correct but may be factually suspect. Edit: left out the word script during a rewite Edited January 26, 2009 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
punisa Posted January 26, 2009 Posted January 26, 2009 So generally don't use Send() MouseClick() WinActivate() WinWaitActive() WinActive() etc.Instead use ControlSend() ControlSetText() ControlClick() WinWait() WinExists() WinMenuSelectItem() etc.I had the same problem when working on remote machines while back and this fixed it. Also I'd recommend using ShellExecute instead of Run when you start something up. Good luck : ) carpe diem
IndyUK Posted January 26, 2009 Posted January 26, 2009 I also had problems with running scripts on a server and it's true that certain Windows activity is suspended while desktops are locked. Since you're running a "windows" applications i.e not Java, you should use the direct control access commands. These will not rely on the screen to be rendered, which is what the problem is and allow the script to keep running. I was doing a Java application which was a real pain as there's no method of direct control manipulation only mousemoves and clicks. Luckly my script ended up on a server which we have setup to run on 5 remote sessions setup and didn't have the problem of locked screen - You could try it this way also. Good luck.
zfisherdrums Posted January 26, 2009 Posted January 26, 2009 Mas domo for the correction, herewasplato. I should NOT have used 'ANY' in my take on the issue. Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog...
neilontherock Posted January 27, 2009 Author Posted January 27, 2009 Mas domo for the correction, herewasplato. I should NOT have used 'ANY' in my take on the issue.Hi - many thanks for all your suggestions but I still cannot get the file to download with the below perl code. The code only works when a user execute it. If I set it up for a scheduled task or via aother scheduling tool it does not download the file. Anyone know if what I am doing here is possible via a scheduled process. It may be an issues with the interaction of the download dialog. use strict; use Win32::IEAutomation; my $ie = Win32::IEAutomation->new( visible => 1, maximize => 1); my $url; $url = 'http://www12.statcan.ca/census-recensement/2006/dp-pd/hlt/97-550/Index.cfm?TPL=P1C&Page=RETR&LANG=Eng&T=101'; $ie->gotoURL($url); $ie->getLink('linktext:', "CSV (comma-separated values) file")->Click; my $autoit = Win32::OLE->new('AutoitX3.Control'); $autoit->WinWait('File Download','', 5); $autoit->ControlClick('File Download', '', '&Save'); $autoit->WinWait('Save As', 'Save &in', 5); $autoit->ControlSetText('Save As', 'Save &in', 'Edit1', 'C:\NDNCL\test.csv'); $autoit->ControlClick('Save As', 'Save &in', '&Save'); $ie->closeIE;
herewasplato Posted January 28, 2009 Posted January 28, 2009 ... It may be an issues with the interaction of the download dialog. ...Listen for the point of failure using Beep() and/or SoundPlay() :-)...your codeBeep()Sleep()... more of your codeBeep()Beep()Sleep()... more of your codeBeep()Beep()Beep()Sleep()............... [size="1"][font="Arial"].[u].[/u][/font][/size]
neilontherock Posted January 29, 2009 Author Posted January 29, 2009 Hi - I am able to get the script to work via a scheduled task but only when I am logged on to the server. I am connected via Remote Desktop, I watch the scheduled task run and it downloads the file. I then set the scheduled task to run again a few minutes ahead, log off the server (which is always running). When I log back into the server my log shows the scheduled task has run but does not download the file. The Autoit script will timeout on the WinWait('Save As', "Save In", 60). I set the timeout to 60 seconds and then added a check after to check for the WinExist('Save As') and it returns 0. If I am logged on to the server via Remote Desktop the exact same code works. My script is configured to run as the Administrator. This is a Window 2003 Server. I'm really hoping someone knows why this is failing and what I can do to make this work. Let me know if you need any further details.
LarryDalooza Posted January 29, 2009 Posted January 29, 2009 You can InetGet() the URL directly... InegGet("http://www12.statcan.ca/census-recensement/2006/dp-pd/hlt/97-550/File.cfm?T=101&SR=1&RPP=25&PR=0&CMA=0&S=0&O=A&LANG=Eng&OFT=CSV","file.csv") Lar. AutoIt has helped make me wealthy
LarryDalooza Posted January 29, 2009 Posted January 29, 2009 If the url changes, get the url via code then InetGet() it. AutoIt has helped make me wealthy
LarryDalooza Posted January 29, 2009 Posted January 29, 2009 No InetGet() in autoitx... There must be a perl Win32::IEAutomation for URLDownload() or something. Lar. AutoIt has helped make me wealthy
neilontherock Posted January 29, 2009 Author Posted January 29, 2009 (edited) No InetGet() in autoitx... There must be a perl Win32::IEAutomation for URLDownload() or something.Lar.Hi - thanks for the reply. The url I specified in my code is just an example of a file download. The real code actually logs on to a secure website using a username and password, then clicks a few links, inputs other data and then clicks a button that will then start the downloading of a zipped file. This all works fine using the Autoit functions except for the interaction with the Download dialog when the scheduled task runs and I am not logged into the server. I cannot post the real code due to security reasons.I don't see a InetGet in the Perl Win32::IEAutomation module. Edited January 29, 2009 by neilontherock
neilontherock Posted January 30, 2009 Author Posted January 30, 2009 (edited) Hi - thanks for the reply. The url I specified in my code is just an example of a file download. The real code actually logs on to a secure website using a username and password, then clicks a few links, inputs other data and then clicks a button that will then start the downloading of a zipped file. This all works fine using the Autoit functions except for the interaction with the Download dialog when the scheduled task runs and I am not logged into the server. I cannot post the real code due to security reasons.I don't see a InetGet in the Perl Win32::IEAutomation module.I am pretty sure the problem here is that the script will not work unless a user is logged on to the server. I am only using the Autoit Active X dll to communicate with the Windows Download dialog and process it. If anyone has any suggestions or knows what I can use to process the download dialog when no user is logged on the server, please let me know. This would be greatly appreciated. The Autoit tools are awesome and I can see lots of reasons to use it in the future.Thanks,Neil Edited January 30, 2009 by neilontherock
herewasplato Posted January 30, 2009 Posted January 30, 2009 ... If anyone has any suggestions ... You might want to do it all in AutoIt3 - glance at this post for a sample of logging into a site:http://www.autoitscript.com/forum/index.ph...st&p=597600I'm not sure if logging into a secure site is an issue or not... but once authenticated, InetGet might work for you. [size="1"][font="Arial"].[u].[/u][/font][/size]
99ojo Posted January 30, 2009 Posted January 30, 2009 Hi, have you try to start remotedesktop session as console: mstsc /v:<server> /console and then the scheduled task should run as aspected. ;-)) Stefan
azure Posted January 30, 2009 Posted January 30, 2009 Hi,have you try to start remotedesktop session as console:mstsc /v:<server> /console and then the scheduled task should run as aspected.;-))StefanExcept that Microsoft removed the /console switch No More CONSOLE
99ojo Posted January 30, 2009 Posted January 30, 2009 Except that Microsoft removed the /console switch No More CONSOLEHi,then you must have vista. the console switch isn't shown, if you call mstsc /?. But it is working. poste your version of mstsc.exe, if the switch doesn't work.;-))
neilontherock Posted January 30, 2009 Author Posted January 30, 2009 You might want to do it all in AutoIt3 - glance at this post for a sample of logging into a site:http://www.autoitscript.com/forum/index.ph...st&p=597600I'm not sure if logging into a secure site is an issue or not... but once authenticated, InetGet might work for you.With InetGet, will I need to know that path of the file on the server? I don't know that information based on the website. All I do is click a button and the file starts downloading. I may be able to get the name of the file because it is a label on the web page.
herewasplato Posted January 30, 2009 Posted January 30, 2009 ... I may be able to get the name of the file because it is a label on the web page.I am probably the worst possible forum member to be helping you with the _IE UDFs. I've never had a need to learn them.The help file for _IEDocReadHTML states in part:This function returns the document source after any client-side modifications (e.g. by AutoIt or by client-side Javascript). It may therefore be different than what is shown by the browser View Source or by _INetGetSource.So you might try _INetGetSource and/or _IEDocReadHTML to discover that path. [size="1"][font="Arial"].[u].[/u][/font][/size]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now