Is it possible to download using the Windows command line?
Starting with Windows 7, I believe there's one single method that hasn't been mentioned yet that's easy:
Syntax:
bitsadmin /transfer job_name /download /priority priority URL local\path\file
Example:
bitsadmin /transfer mydownloadjob /download /priority normal ^ http://example.com/filename.zip C:\Users\username\Downloads\filename.zip
(Broken into two separate lines with ^
for readability
(to avoid scrolling).)
Warning: As pointed out in the comments,
the bitsadmin
help message starts by saying:
BITSAdmin is deprecated and is not guaranteed to be available in future versions of Windows.
Administrative tools for the BITS service are now provided by BITS PowerShell cmdlets.
... but another comment reported that it works on Windows 8.
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
Windows 7 includes PowerShell and there's pretty much nothing you can't do with PowerShell.
Native alternative to wget in Windows PowerShell?