Home » Questions » Computers [ Ask a new question ]

Is it possible to download using the Windows command line?

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?

Asked by: Guest | Views: 226
Total answers/comments: 5
Guest [Entry]

"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"
Guest [Entry]

"Windows 7 includes PowerShell and there's pretty much nothing you can't do with PowerShell.

Native alternative to wget in Windows PowerShell?"
Guest [Entry]

"Windows Explorer (not to be confused with Internet Explorer) can download files via HTTP. Just enter the URL into the Address bar. Or from the command line, for example, C:\windows\explorer.exe http://somewhere.com/filename.ext.

You get the classic File Download prompt. Unless the file is a type that Windows Explorer knows how to display inline, (.html, .jpg, .gif), in which case you would then need to right-click to save it.

I just tested this on my VMware image of a virgin install of Windows XP 2002 SP1, and it works fine."
Guest [Entry]

"You can use (in a standard Windows bat):

powershell -command ""& { iwr http://www.it1.net/it1_logo2.jpg -OutFile logo.jpg }""

It seems to require PowerShell v4...

(Thanks to that comment and this one)"
Guest [Entry]

"Use FTP.

From the command line:

ftp ftp.somesite.com
user
password

etc. FTP is included in every Windows version I can remember; probably not in 3.1, maybe not in Windows 95, but certainly everything after that.

@RM: It is going to be rough if you don't want to download any other tools. There exists a command line Wget for Windows and Wget is designed to do exactly what you're asking for."