Solved

Programatically download EXE from web into specified directory.

Posted on 2004-10-13
5
527 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
  • 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now