Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Programatically download EXE from web into specified directory.

Posted on 2004-10-13
5
Medium Priority
?
535 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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

916 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