Jump to content

Recommended Posts

Posted

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()
Posted

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

Posted

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.

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
Posted

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.

Posted

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?

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
  • Recently Browsing   0 members

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