Sign in to follow this  
Followers 0
napgravy

URLDownloadToFile question

14 posts in this topic

Hello all.

I wrote a simple script using AutoIt3 v3.0.86 that uses the URLDownloadToFile function. See below:

;AutoItSetOption("RunErrorsFatal",0)

$File = "symcdefsx86.exe"

$FtpFile = "ftp://ftp.symantec.com/public/english_us_canada/antivirus_definitions/norton_antivirus/static/" & $File

$LocFile = @WorkingDir & "\" & $File

$Pwd = "password"

SplashTextOn("",@CRLF & "Please Wait",300,70,100,100)
URLDownloadToFile($FtpFile,$LocFile)
SplashOff()
RunAsSet("Administrator", @ComputerName, $Pwd)
MsgBox(4096,"Msg","RunAsSet completed")
Run($LocFile, @WorkingDir)
MsgBox(4096,"Msg","Run completed")
RunAsSet()

Exit

(the $FtpFile line above is being wrapped because its too long...)

What this code should do is obtain the latest self-extracting Norton Antivirus defs from Symantec's FTP site and install them. Users at our location are not Administrator-level thus the need for a "RunAsSet" to install as local Administrator.

The problem I'm having is that the file downloads okay (about 7.5MB) and then the script bails. The splash goes away and you can see the two MsgBox commands pop up for an instant and then disappear. The "Run" command never starts "$LocFile".

If I comment out the URLDownloadToFile line, the script works fine - provided the symcdefsx86.exe file has already been downloaded.

What have I missed?

nap

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

seemed to work fine for me, but I would put a runwait in for the last part.

; beginning of your script...
Runwait($LocFile, @WorkingDir); this will wait till it is finished before running.
MsgBox(4096,"Msg","Run completed")
RunAsSet()

Exit

edit.. I did have to make sure to use the local system username and password, and you still need to have your subscriptions up to date.

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

seemed to work fine for me, but I would put a runwait in for the last part.

Thanks for the quick reply!

Unfortunately, I can't use a RunWait. In my more "elaborate" version of the script, I

also take care of "answering" the self-extracting def update's prompts with the following:

WinWaitActive("Symantec Security Response Intelligent Updater")
Send("!y")
WinWaitActive("Symantec Security Response Intelligent Updater","Thank you")
Send("{ENTER}")

Obviously if I use a Runwait, this won't work. :whistle: The sample script I posted initially was seriously trimmed down just to show the basic issue I was having.

I haven't searched around yet to see if there is any sort of "debug mode" that I can start AutoIt with. I'll do some more poking around to see if I can figure out whats going on but it still fails here every time as long as I leave the URLDownloadToFile line in...

nap

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

ok, you might be using WinExists ( "title", ["text"] ) in your full version, as in

; beginning of your script...
Run($LocFile, @WorkingDir); this will wait till it is finished before running.
while WinExists ( "Symantec", ["text"] ) 
sleep(500)
Wend
MsgBox(4096,"Msg","Run completed")
RunAsSet()

Exit

The download seemed to work fine for me, you might use two scripts to do this.

; first one first.au3 before compile
;AutoItSetOption("RunErrorsFatal",0)

$File = "symcdefsx86.exe"

$FtpFile = "ftp://ftp.symantec.com/public/english_us_canada/antivirus_definitions/norton_antivirus/static/" & $File
$LocFile = @WorkingDir & "\" & $File


SplashTextOn("",@CRLF & "Please Wait",300,70,100,100)
URLDownloadToFile($FtpFile,$LocFile)
SplashOff()

; install.au3
runwait("first.exe")
$File = "symcdefsx86.exe"
$LocFile = @WorkingDir & "\" & $File
$Pwd = "password"
RunAsSet("Administrator", @ComputerName, $Pwd)
MsgBox(4096,"Msg","RunAsSet completed")
Run($LocFile, @WorkingDir)
MsgBox(4096,"Msg","Run completed")
RunAsSet()

Exit

or just make a simple version and use commandlines:

;Symantec downloader
; SDown.au3
;AutoItSetOption("RunErrorsFatal",0)
if $CmdLine[0]<1 then exit 
$File = $CmdLine[1] 

$FtpFile = "ftp://ftp.symantec.com/public/english_us_canada/antivirus_definitions/norton_antivirus/static/" & $File
$LocFile = @WorkingDir & "\" & $File
SplashTextOn("",@CRLF & "Please Wait",300,70,100,100)
URLDownloadToFile($FtpFile,$LocFile)
SplashOff()

and

; install.au3
$File = "symcdefsx86.exe"
$LocFile = @WorkingDir & "\" & $File
$Pwd = "password"
runwait("SDown.exe "& $file)
RunAsSet("Administrator", @ComputerName, $Pwd)
MsgBox(4096,"Msg","RunAsSet completed")
Run($LocFile, @WorkingDir)
MsgBox(4096,"Msg","Run completed")
RunAsSet()

Exit

You can use fileinstall() in it and filedelete the tiny exe after.

Well hope it helps.

...when all else fails, consider it a feature and a challenge to find a work around.

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

You can use RunWait and set up AdLib to handle the windows that may pop up (I think, been a long time since I had to use AdLib).

Share this post


Link to post
Share on other sites

Thanks for the replies guys...

I will give your suggestions a whirl 'till I get something cobbled together that works! :whistle:

On a side note... After a bit more testing, I found that I can simplify my test script even more and still reproduce the failure:

$File = "symcdefsx86.exe"

$FtpFile = "ftp://ftp.symante[...]public/" & $File

$LocFile = @WorkingDir & "\" & $File

MsgBox(4096,"Msg",$FtpFile & @CRLF & $LocFile)

URLDownloadToFile($FtpFile,$LocFile)

MsgBox(4096,"Msg","URLDownloadToFile completed")

Exit

The first MsgBox pops up, I click OK, the file is downloaded, and then the script exists. The 2nd MsgBox displays for a sec and then disappears - I never get a chance to click on OK. I'm wondering if this might not be an AutoIt problem but instead a problem with what AutoIt calls to perform the download...

nap

Share this post


Link to post
Share on other sites

Just a side note, have you tried downloading anything else this way? What OS? Only FTP that has the problem?

I tested your script on WinXP and Win2000 so far.


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

guys, just tested the script on my WinXP and my autoIt crashed after the download when it just showed de msgbox. This is my test script

$File = "update.txt"; change to a smaller file for testing
$FtpFile = "ftp://ftp.symantec.com/public/english_us_canada/antivirus_definitions/norton_antivirus/static/" & $File
$LocFile = @WorkingDir & "\" & $File
MsgBox(4096,"Msg",$FtpFile & @CRLF & $LocFile)
$rc = URLDownloadToFile($FtpFile,$LocFile)
MsgBox(4096,"Msg","URLDownloadToFile completed rc:" & $rc)
Exit

tried to run it with 3.0.85 & 3.0.86 & unstable 3.0.87..

All crash with the following debug info :

<?xml version="1.0" encoding="UTF-16"?>

<DATABASE>

<EXE NAME="AutoIt3.exe" FILTER="GRABMI_FILTER_PRIVACY">

    <MATCHING_FILE NAME="Aut2Exe.exe" SIZE="65024" CHECKSUM="0x815558A9" BIN_FILE_VERSION="3.0.87.0" BIN_PRODUCT_VERSION="3.0.87.0" PRODUCT_VERSION="3, 0, 87, 0" FILE_DESCRIPTION="Aut2Exe" COMPANY_NAME="" PRODUCT_NAME="Aut2Exe" FILE_VERSION="3, 0, 87, 0" ORIGINAL_FILENAME="Aut2Exe.exe" INTERNAL_NAME="Aut2Exe" LEGAL_COPYRIGHT="©1999-2004 Jonathan Bennett &amp; AutoIt Team" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="3.0.87.0" UPTO_BIN_PRODUCT_VERSION="3.0.87.0" LINK_DATE="01/15/2004 17:03:35" UPTO_LINK_DATE="01/15/2004 17:03:35" VER_LANGUAGE="English (United Kingdom) [0x809]" />

    <MATCHING_FILE NAME="AutoIt3.exe" SIZE="81408" CHECKSUM="0xA595194F" BIN_FILE_VERSION="3.0.87.0" BIN_PRODUCT_VERSION="3.0.87.0" PRODUCT_VERSION="3, 0, 87, 0" FILE_DESCRIPTION="AutoIt v3 Script (BETA)" PRODUCT_NAME="AutoIt v3 Script" FILE_VERSION="3, 0, 87, 0" ORIGINAL_FILENAME="AutoIt3.exe" INTERNAL_NAME="AutoIt3.exe" LEGAL_COPYRIGHT="©1999-2004 Jonathan Bennett &amp; AutoIt Team" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x0" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="3.0.87.0" UPTO_BIN_PRODUCT_VERSION="3.0.87.0" LINK_DATE="01/15/2004 17:15:07" UPTO_LINK_DATE="01/15/2004 17:15:07" VER_LANGUAGE="English (United Kingdom) [0x809]" />

    <MATCHING_FILE NAME="upx.exe" SIZE="94208" CHECKSUM="0x6753983A" BIN_FILE_VERSION="1.24.0.0" BIN_PRODUCT_VERSION="1.24.0.0" PRODUCT_VERSION="1.24" FILE_DESCRIPTION="UPX executable packer" COMPANY_NAME="The UPX Team http://upx.sf.net" PRODUCT_NAME="UPX" FILE_VERSION="1.24" ORIGINAL_FILENAME="upx.exe" INTERNAL_NAME="upx.exe" LEGAL_COPYRIGHT="© 1996-2002 Markus F.X.J. Oberhumer" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="1.24.0.0" UPTO_BIN_PRODUCT_VERSION="1.24.0.0" LINK_DATE="11/07/2002 13:13:18" UPTO_LINK_DATE="11/07/2002 13:13:18" VER_LANGUAGE="English (United States) [0x409]" />

</EXE>

<EXE NAME="kernel32.dll" FILTER="GRABMI_FILTER_THISFILEONLY">

    <MATCHING_FILE NAME="kernel32.dll" SIZE="930304" CHECKSUM="0xCBCCF8A9" BIN_FILE_VERSION="5.1.2600.1106" BIN_PRODUCT_VERSION="5.1.2600.1106" PRODUCT_VERSION="5.1.2600.1106" FILE_DESCRIPTION="Windows NT BASE API Client DLL" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft® Windows® Operating System" FILE_VERSION="5.1.2600.1106 (xpsp1.020828-1920)" ORIGINAL_FILENAME="kernel32" INTERNAL_NAME="kernel32" LEGAL_COPYRIGHT="© Microsoft Corporation. All rights reserved." VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0xE7ED3" LINKER_VERSION="0x50001" UPTO_BIN_FILE_VERSION="5.1.2600.1106" UPTO_BIN_PRODUCT_VERSION="5.1.2600.1106" LINK_DATE="08/29/2002 10:40:40" UPTO_LINK_DATE="08/29/2002 10:40:40" VER_LANGUAGE="English (United States) [0x409]" />

</EXE>

</DATABASE>


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Ok, one WinXP machine I was able to get the same error and such. I added a sleep function, and I went "wow that worked" then I removed it and realised I was just not getting the error anymore no matter what I tried.

$File = "update.txt"; changed to a smaller file for testing
$FtpFile = "ftp://ftp.symantec.com/public/english_us_canada_
/antivirus_definitions/norton_antivirus/static/" & $File
$LocFile = @WorkingDir & "\" & $File
MsgBox(4096,"Msg",$FtpFile & @CRLF & $LocFile)
$rc = URLDownloadToFile($FtpFile,$LocFile)
MsgBox(4096,"Msg","URLDownloadToFile completed rc:" & $rc)
Exit

Good luck, this one is a wierd bug.


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

I agree with the timing thing you noticed... looks like i don't have it the first time i run the script after a while and when run for the second time it crashes and keeps on crashing

Maybe we need to report in the BUGS report section if other see the same?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I've been having trouble with URLDownload if I call a msgbox straight after - full on crash. There is definately a bug there and I can replicate it but can't seem to find a fix. As a crappy workaround, make sure there is a Sleep() delay after the URL download function.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

did some more testing on it... once crashed it keeps on crashing and sleep doesn't solve it... :whistle:

Just as a workaround you could use CURL to download the file. that a pretty complete commandline program to do ftp & http ....

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

did some more testing on it... once crashed it keeps on crashing and sleep doesn't solve it... B)

Just as a workaround you could use CURL to download the file. that a pretty complete commandline program to do ftp & http ....

Wow - a flurry of activity in this thread now! :whistle:

I've added a Sleep to my test script and it works almost every time now. It has still failed once or twice though. Good idea about just using a stand-alone program like curl or wget to get the file though. That is probably the safest route 'till the bug is squashed.

Thanks for all of your help guys. Hopefully you can track down that bug eventually!

nap

Share this post


Link to post
Share on other sites

Just a side note, have you tried downloading anything else this way? What OS? Only FTP that has the problem?

I tested your script on WinXP and Win2000 so far.

If it makes any difference, we use W2K w/SP3, IE6SP1, and several hotfixes.

If there is anything else I can provide to help track down the cause, let me know.

nap

Share this post


Link to post
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
Sign in to follow this  
Followers 0