Solved

Programatically download EXE from web into specified directory.

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

752 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