'====================================================================== ' http-download.vbs 1.0 @2011 by Frank4dd http://fm4dd.com/programming ' This script demonstrates a file download from a webserver using http. ' It can easily be extended for using basic web authentication ' ' This program comes with ABSOLUTELY NO WARRANTY. You may redistribute ' copies of it under the terms of the GNU General Public License. '====================================================================== '====================================================================== ' Global Constants and Variables '====================================================================== Const scriptVer = "1.0" Const DownloadDest = "http://fm4dd.com/images/logo.gif" Const LocalFile = "C:\tmp.gif" 'Const UploadUser = "username" 'Const UploadPass = "password" Const DownloadType = "binary" dim strURL function getit() dim xmlhttp set xmlhttp=createobject("MSXML2.XMLHTTP.3.0") 'xmlhttp.SetOption 2, 13056 'If https -> Ignore all SSL errors strURL = DownloadDest msgbox "Download-URL: " & strURL xmlhttp.Open "GET", strURL, false xmlhttp.Send Wscript.Echo "Download-Status: " & xmlhttp.Status & " " & xmlhttp.statusText If xmlhttp.Status = 200 Then Dim objStream set objStream = CreateObject("ADODB.Stream") objStream.Type = 1 'adTypeBinary objStream.Open objStream.Write xmlhttp.responseBody objStream.SaveToFile LocalFile objStream.Close set objStream = Nothing End If set xmlhttp=Nothing End function '======================================================================= ' End Function Defs, Start Main '======================================================================= ' Get cmdline params and initialize variables If Wscript.Arguments.Named.Exists("h") Then Wscript.Echo "Usage: http-download.vbs" Wscript.Echo "version " & scriptVer WScript.Quit(intOK) End If getit() Wscript.Echo "Download Complete. See " & LocalFile & " for success." Wscript.Quit(intOK) '======================================================================= ' End Main '=======================================================================