Solved

Programatically download EXE from web into specified directory.

Posted on 2004-10-13
5
532 Views
Last Modified: 2007-11-27
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?
0
Comment
Question by:csho
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 11

Expert Comment

by:bingie
ID: 12302270
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
0
 

Author Comment

by:csho
ID: 12302460
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?
0
 
LVL 11

Accepted Solution

by:
bingie earned 250 total points
ID: 12302708
Sorry, and your path. Try this instead:

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, myPath As String)
    Dim fName As String
    myPath = myPath
    fileName = "myExe.exe"
    URLDownloadToFile 0&, URL, myPath & fileName, &H10, 0&
End Function

Private Sub Form_Load()
    Call DownloadToFile (yourUrl, yourPath)
End Sub
0
 

Author Comment

by:csho
ID: 12307579
Thanks a ton, kind of scary this can be done so easily...shouldn't some security setting prohibit this?
0
 
LVL 11

Expert Comment

by:bingie
ID: 12311955
No trouble, leave some feedback if you like :)
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month5 days, 23 hours left to enroll

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question