Download a file with VBS

You can download using XMLHTTP and leverage an ADO stream to write the binary data;

dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")
dim bStrm: Set bStrm = createobject("Adodb.Stream")
xHttp.Open "GET", "http://example.com/someimage.png", False
xHttp.Send

with bStrm
    .type = 1 '//binary
    .open
    .write xHttp.responseBody
    .savetofile "c:\temp\someimage.png", 2 '//overwrite
end with

Leave a Comment