Submitted By: Andrew Stepleton

Uses ADODB.Stream to download a file from the Internet and save it to the local hard drive.

Visual Basic
Edit|Remove
SourceURL  = "http://www.microsoft.com/library/media/1033/technet/images/scriptcenter/welder-small.jpg"
FileSaveAs = "c:\Scripts\welder-small.jpg"

Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2

Set oHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
Set oStream = CreateObject("ADODB.Stream")

oHTTP.SetProxy 2,"ProxyAddress:Port"
oHTTP.Open "GET", SourceURL, False
oHTTP.Send

If (oHTTP.Status = 200) Then
   oStream.Open
   oStream.Type = adTypeBinary
   oStream.Write oHTTP.ResponseBody
   oStream.SaveToFile FileSaveAs, adSaveCreateOverWrite
   oStream.Close
Else
   WScript.Echo "Error Number: " & oHTTP.Status
   WScript.Echo "Error Text: " & oHTTP.StatusText
End If