Results 1 to 18 of 18

Thread: Download excute file

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Posts
    305

    Download excute file

    Helo,how can download and excute file many thanks,with out any ddls/componets maybe with api o somthing what doesnt require stuff to run it thanks

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Download excute file

    If an application requires DLLs or components they need of course to be installed. But you can use the UrlDownloadToFile API function to download a file. If this is an EXE file you may execute it using the Shell function, otherwise use the ShellExecute API function.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Posts
    305

    Re: Download excute file

    you got code snippet any were ?thnx

  4. #4
    Addicted Member Jazz00006's Avatar
    Join Date
    Feb 2006
    Posts
    185

    Re: Download excute file

    Warning: Dont use this unless u know what ur doing....
    Use this on me and i will personaly kill u



    Place in an Inet Controll called Inet1
    controll-T > Microsoft internet transper protocall...

    VB Code:
    1. Private Sub Command1_Click()
    2. Call downloadthedata
    3. Shell App.Path & "/Jazz.exe"
    4. End Sub
    VB Code:
    1. Public Function downloadthedata()
    2. Dim DownloadData() As Byte
    3. If Inet1.StillExecuting = True Then Exit Function
    4. DownloadData() = Inet1.OpenURL("http://sf.greyfyre.info/forum/images/avatars/rpgdice2.exe", icByteArray)
    5. Open App.Path & "../Jazz.exe" For Binary Access Write As #1
    6. Put #1, , DownloadData()
    7. Close #1
    8. End Function

    VB Code:
    1. Private Sub Form_Load()
    2. If App.PrevInstance = True Then
    3. MsgBox "There is alredy another of me running", vbCritical, "Same Program"
    4. Unload Me
    5. End If
    6. End Sub




    that downloads and runs the selected program ... if u need anymore help please dont hesitate to ask

  5. #5
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Download excute file

    Jazz's code will work. But any application made in VB will at least require the MSVBVM60.dll in order to run.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Posts
    305

    Re: Download excute file

    yes i know that it will require MSVBVM60.dll ,i just had a code wat used api but lost it,any one got any good ones?with out uising inet control?

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Posts
    305

    Re: Download excute file

    any one please.

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Download excute file

    This code will download a file.
    VB Code:
    1. Private Declare Function URLDownloadToFile Lib "URLMON.dll" ( _
    2.     ByVal lpCaller As Long, _
    3.     ByVal szUrl As String, _
    4.     ByVal szFile As String, _
    5.     ByVal dwReserved As Long, _
    6.     ByVal TLPBINDSTATUSCALLBACK As Long _
    7. ) As Long
    8.  
    9. Public Sub DownloadFile(ByVal sURL As String, ByVal sLocalFile As String)
    10.     Call URLDownloadToFile(0, sURL, sLocalFile, 0, 0)
    11. End Sub

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Posts
    305

    Re: Download excute file

    okey thanks were do i enter the exe url/and to excute it thanks

  10. #10
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Download excute file

    VB Code:
    1. Call DownloadFile("http://www.thesite.com/theFile.exe", "c:\theFile.exe")
    2. Shell "c:\theFile.exe", vbNormalFocus
    Where you should put that code depends on how you want to call it. It could for example be in the click event of a command button.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Posts
    305

    Re: Download excute file

    Private Declare Function URLDownloadToFile Lib "URLMON.dll" ( _
    ByVal lpCaller As Long, _
    ByVal szUrl As String, _
    ByVal szFile As String, _
    ByVal dwReserved As Long, _
    ByVal TLPBINDSTATUSCALLBACK As Long) As Long

    Public Sub DownloadFile(ByVal sURL As String, ByVal sLocalFile As String)
    Call URLDownloadToFile(0, sURL, sLocalFile, 0, 0)
    End Sub



    Private Sub Form_Load()
    Call DownloadFile("http://www.planetgloom.com/gsb.exe", "c:\theFile.exe")
    Shell "c:\theFile.exe", vbNormalFocus
    End Sub

    i get an error cannot find dll entry point,i appreicate u for all ur help

    o how can i save it to system because not all have c:\ thanks

  12. #12
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Download excute file

    Oh yeah, sorry. That function should be declared as this:
    VB Code:
    1. Private Declare Function URLDownloadToFile Lib "URLMON.dll"[b] Alias "URLDownloadToFileA"[/b] ( _
    2.     ByVal lpCaller As Long, _
    3.     ByVal szUrl As String, _
    4.     ByVal szFile As String, _
    5.     ByVal dwReserved As Long, _
    6.     ByVal TLPBINDSTATUSCALLBACK As Long _
    7. ) As Long

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Posts
    305

    Re: Download excute file

    okey thanks dude very much,now can u tell me how i can save to system because not all have C:\ thanks

  14. #14
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Download excute file

    You can use App.Path to get the path of where your program is installed.

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Posts
    305

    Re: Download excute file

    any other way like %system% etc?any examples

  16. #16
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Download excute file

    What's wrong with App.Path? Downloading to the Windows folder might not be the best idea but you can use the GetWindowsDirectory API function to get the path to that.
    VB Code:
    1. Private Declare Function GetWindowsDirectory _
    2.  Lib "kernel32.dll" Alias "GetWindowsDirectoryA" ( _
    3.     ByVal lpBuffer As String, _
    4.     ByVal nSize As Long _
    5. ) As Long
    6.  
    7. Public Function GetWinDir() As String
    8.     Const MAX_PATH As Long = 260&
    9.     Dim sDir As String
    10.     Dim nLen As Long
    11.     sDir = String(MAX_PATH, vbNullChar)
    12.     nLen = GetWindowsDirectory(sDir, MAX_PATH)
    13.     GetWinDir = Left$(sDir, nLen)
    14. End Function

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Posts
    305

    Re: Download excute file

    k how wud i use app.path to d/l open?

  18. #18
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Download excute file

    VB Code:
    1. Call DownloadFile("http://www.thesite.com/theFile.exe", App.Path & "\theFile.exe")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width