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
Printable View
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
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.
you got code snippet any were :D?thnx
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:
Private Sub Command1_Click() Call downloadthedata Shell App.Path & "/Jazz.exe" End SubVB Code:
Public Function downloadthedata() Dim DownloadData() As Byte If Inet1.StillExecuting = True Then Exit Function DownloadData() = Inet1.OpenURL("http://sf.greyfyre.info/forum/images/avatars/rpgdice2.exe", icByteArray) Open App.Path & "../Jazz.exe" For Binary Access Write As #1 Put #1, , DownloadData() Close #1 End Function
VB Code:
Private Sub Form_Load() If App.PrevInstance = True Then MsgBox "There is alredy another of me running", vbCritical, "Same Program" Unload Me End If End Sub
that downloads and runs the selected program ... if u need anymore help please dont hesitate to ask
Jazz's code will work. But any application made in VB will at least require the MSVBVM60.dll in order to run.
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?
any one please.
This code will download a file.VB Code:
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
okey thanks were do i enter the exe url/and to excute it thanks
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.VB Code:
Call DownloadFile("http://www.thesite.com/theFile.exe", "c:\theFile.exe") Shell "c:\theFile.exe", vbNormalFocus
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
Oh yeah, sorry. That function should be declared as this:VB Code:
Private Declare Function URLDownloadToFile Lib "URLMON.dll"[b] Alias "URLDownloadToFileA"[/b] ( _ ByVal lpCaller As Long, _ ByVal szUrl As String, _ ByVal szFile As String, _ ByVal dwReserved As Long, _ ByVal TLPBINDSTATUSCALLBACK As Long _ ) As Long
okey thanks dude very much,now can u tell me how i can save to system because not all have C:\ thanks
You can use App.Path to get the path of where your program is installed.
any other way like %system% etc?any examples
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:
Private Declare Function GetWindowsDirectory _ Lib "kernel32.dll" Alias "GetWindowsDirectoryA" ( _ ByVal lpBuffer As String, _ ByVal nSize As Long _ ) As Long Public Function GetWinDir() As String Const MAX_PATH As Long = 260& Dim sDir As String Dim nLen As Long sDir = String(MAX_PATH, vbNullChar) nLen = GetWindowsDirectory(sDir, MAX_PATH) GetWinDir = Left$(sDir, nLen) End Function
k how wud i use app.path to d/l open?
VB Code:
Call DownloadFile("http://www.thesite.com/theFile.exe", App.Path & "\theFile.exe")