Sign in to follow this  
Followers 0
sayru

download URL file and execute file

7 posts in this topic

how can i make auto-it download a file from given URL, and run it ?

I want the file to be saved automatically to Program File. Once it's downloaded, I need to run the file.

I found this code but it prompts to save the file.

$FileURL = "http://somesite.com/setup.exe"
$FileName = "Setup.exe"
$FileSaveLocation = FileSaveDialog("Save Location...",@ScriptDir,"All (*.*)",18,$FileName)
$FileSize = InetGetSize($FileURL)

InetGet($FileURL,$FileName,0,1)

ProgressOn("","")
While @InetGetActive
    $Percentage = @InetGetBytesRead * 100 / $FileSize
    ProgressSet($Percentage,"Downloaded " & @InetGetBytesRead & " of " & $FileSize & " bytes","Downloading " & $FileName)
    Sleep(250)
Wend
ProgressOff()

Share this post


Link to post
Share on other sites



Hi,

this line causes the prompt:

$FileSaveLocation = FileSaveDialog("Save Location...",@ScriptDir,"All (*.*)",18,$FileName)

If you don't want it, you may code like this, to save setup.exe into temp folder:

$FileURL = "http://somesite.com/setup.exe"
$FileName = @TempDir & "\Setup.exe"
;$FileSaveLocation = FileSaveDialog("Save Location...",@ScriptDir,"All (*.*)",18,$FileName)
$FileSize = InetGetSize($FileURL)

InetGet($FileURL,$FileName,0,1)

ProgressOn("","")
While @InetGetActive
    $Percentage = @InetGetBytesRead * 100 / $FileSize
    ProgressSet($Percentage,"Downloaded " & @InetGetBytesRead & " of " & $FileSize & " bytes","Downloading " & $FileName)
    Sleep(250)
Wend
ProgressOff()
;ShellExecute (@TempDir & "\setup.exe") ; you may use Run (), RunWait () or ShellExecuteWait depending on setup.exe

;-))

Stefan

Share this post


Link to post
Share on other sites

FileCopy("http://somesite.com/setup.exe","c:\",9) should do the trick

Shelexecute("c:\setup.exe") should start it after download finish

You may need to add somesite.com to the trusted sites to avoid pop-ups and security prompts.

Share this post


Link to post
Share on other sites

FileCopy didn't work.... i didn't know it accepted URL ?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

On beta version this work fine.

$DOWNLOAD_LINK = "http://quicklz.com/qpress.exe"
$PATH = @ProgramFilesDir & "\qpress.exe"
If Not @error Then
    $INET = InetGet($DOWNLOAD_LINK,$PATH,1,1)
    Do
        TrayTip("Download",InetGetInfo($INET,0) & "/" & InetGetInfo($INET,1),1)
    Until InetGetInfo($INET,2)
    InetClose($INET)
    ShellExecute($PATH)
EndIf

EDIT: Without to prompt where you want to save the file.

Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites

FileCopy didn't work.... i didn't know it accepted URL ?

http://quicklz.com/qpress.exe - wont work with this site,sorry i forgot to check.

try what 99ojo suggested - works for me.

Share this post


Link to post
Share on other sites

http://quicklz.com/qpress.exe - wont work with this site,sorry i forgot to check.

try what 99ojo suggested - works for me.

What will not work with there site?

When the words fail... music speaks

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