Link to home
Start Free TrialLog in
Avatar of csho
cshoFlag for United States of America

asked on

Programatically download EXE from web into specified directory.

I want to be able to download an executable from an internet site into a specified folder. I want to have my cake and eat it to in that I don't want to decrease my security settings, yet I also don't want to see any warnings. Can this be done?
Avatar of bingie
bingie

Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long

Function DownloadToFile(URL As String, Path As String)
    Dim fName As String
    myPath = "c:\" ' you path to download to
    fileName = "myExe.exe"
    URLDownloadToFile 0&, URL, myPath & fName, &H10, 0&
End Function

Private Sub Form_Load()
    DownloadFile yourUrl
End Sub
Avatar of csho

ASKER

Maybe I should have said I'm using vb 5.0...does this make a difference? This doesn't seem to work.

I'm guessing on theload, it should be DownloadToFile and then my url, correct?
ASKER CERTIFIED SOLUTION
Avatar of bingie
bingie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of csho

ASKER

Thanks a ton, kind of scary this can be done so easily...shouldn't some security setting prohibit this?
No trouble, leave some feedback if you like :)