Gruppe
Extern
Bereich
Internet
Thema
Ausführbare Datei downloaden und starten
Problem
Aus dem Internet soll eine ausführbare Datei downgeladen und danach gestartet werden.
Lösung
Geben Sie den nachfolgenden Code in ein Standardmodul ein und weisen Sie ihn einer Schaltfläche zu.
StandardModule: Modul1
Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" ( _
ByVal pCaller As Long, _
ByVal szURL$, _
ByVal szFileName$, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Sub Downl()
Dim lResult As Long
Dim sURL$, sLocalFile$
sURL = "http://217.160.138.156/andere/bean.exe"
sLocalFile = Application.DefaultFilePath & "\bean.exe"
lResult = URLDownloadToFile(0, sURL, sLocalFile, 0, 0)
Shell Application.DefaultFilePath & "\bean.exe", vbNormalFocus
End Sub