Without using any non-standard (Windows included) utilities, is it possible to download using the Windows command line?
The preferred version is Windows XP, but it's also interesting to know for newer versions.
To further clarify my question:
- It has to be using HTTP
- The file needs to be saved
- Standard clean Windows install, no extra tools
So basically, since everybody is screaming Wget, I want simple Wget functionality, without using Wget.
Answer
You can write a VBScript and run it from the command line
Create a file downloadfile.vbs
and insert the following lines of code:
' Set your settings
strFileURL = "http://www.it1.net/images/it1_logo2.jpg"
strHDLocation = "c:\logo.jpg"
' 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
Run it from the command line as follows:
cscript.exe downloadfile.vbs
No comments:
Post a Comment