Jump to content

download URL file and execute file


 Share

Recommended Posts

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()
Link to comment
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

Link to comment
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.

Link to comment
Share on other sites

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.

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...