VBScript based wget
Posted in on Monday, June 25, 2012 by cam
I was using Windows based SSH box the other day and I needed to get some files, but the only options on a limited Windows (XP) box are ftp and the files I wanted were on HTTP so I hunted around and added to a vbscript which created a Wget type script which works via VBScript (which is avaliable on a limited XP Box)
Something else which is good about this script is that it uses Internet Explorer Proxy settings automatically, so if you are behind a corporate firewall and need to go through a proxy it does this automatically for you!
' VBScript based WGET - Changes by Cam McKenzie ' cam.mckenzie --at-- gmail --dot-- com ' USAGE: cscript wget.vbs http://somewhere.com/somefile.zip ' Credit to Chrissy at blog.netnerds.net for the hardwork ' URL to download from command line strFileURL = Wscript.Arguments.Item(0) ' Find current directory Dim sCurPath sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".") ' Get filename from URL Dim UrlArray UrlArray = Split(strFileURL, "/", -1,1) TopOfArray = UBound(UrlArray) ' Where to save the file strHDLocation = sCurPath & "" & UrlArray(TopOfArray) ' 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