Web – Is it possible to download using the Windows command line?

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.

Solution:

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 ThenSet objADOStream = CreateObject("ADODB.Stream")objADOStream.OpenobjADOStream.Type = 1 'adTypeBinaryobjADOStream.Write objXMLHTTP.ResponseBodyobjADOStream.Position = 0    'Set the stream position to the startSet objFSO = CreateObject("Scripting.FileSystemObject")If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocationSet objFSO = NothingobjADOStream.SaveToFile strHDLocationobjADOStream.CloseSet objADOStream = NothingEnd ifSet objXMLHTTP = Nothing

Run it from the command line as follows:

cscript.exe downloadfile.vbs