Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
4  
More ideas in "If the only browser in Windows is dead, how to connect to the Internet?" at superuser.com/questions/50427/… –  Arjan Oct 23 '09 at 15:16
    
And which out of the dozen Windows XP versions would that be? –  Arjan Oct 23 '09 at 15:17
    
Let's say it can be any windows XP SP2 version and everything released later. –  Robert Massa Oct 23 '09 at 15:19
    
@arjan Interesting question, but there's still no definitive answer. –  Robert Massa Oct 23 '09 at 15:19
    
I should have asked for "edition". Like Starter, Home, Professional, Media Center, Tablet, maybe even Embedded (good change for tools there I guess!)... Or the European versions without Windows Media Player. :-) –  Arjan Oct 23 '09 at 15:35

13 Answers 13

up vote 30 down vote accepted

You can write a VBScript and run it from the command line

Create a file downloadfile.vbs and insert the following contents:

' 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 
share|improve this answer
1  
I wonder if this relies on Internet Explorer, but I guess this would be a fine answer for "If the only browser in Windows is dead, how to connect to the Internet?" at superuser.com/questions/50427/… :-) –  Arjan Oct 23 '09 at 15:37

Starting with Windows 7, I believe there's one single method that hasn't been mentioned yet that's easy:

bitsadmin /transfer mydownloadjob  /download /priority normal http://path/to/file c:\path\local\file
share|improve this answer
1  
This looks like the kind of tool the OP was looking for, but it is not a standard part of a Windows install, you have to install it separately. Useful tool though. –  Reed Hedges Jul 22 '11 at 15:42
12  
it is part of windows7. –  akira Aug 20 '11 at 4:20
2  
didn't work on my windows 7... –  jyzuz Apr 5 '12 at 0:14
3  
This should have been the top-voted answer. bitsadmin is deprecated in favor of Windows powershell though. –  lenkite May 14 '12 at 9:04
4  
Note: 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. –  Ujjwal Singh Jan 1 '13 at 20:33

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

Native alternative to wget in Windows PowerShell?

share|improve this answer
12  
(New-Object Net.WebClient).DownloadFile('someurl', 'somepath') –  Jason Stangroome Nov 17 '11 at 2:52
3  
Powershell is for Powerrangers ! How kool is that and why the heck didn't I know about this? Byebye cmd. –  kaiser Dec 10 '12 at 7:45
2  
from cmd.exe: powershell -command "& { iwr http://www.it1.net/it1_logo2.jpg -OutFile logo.jpg }". also works from the run prompt –  Janus Troelsen Jun 3 at 11:57

I found a way of doing it, but really, just install Wget.

You can use Internet Explorer from a command line (iexplore.exe) and then enter a URL as an argument. So, run:

iexplore.exe http://blah.com/filename.zip

Whatever the file is, you'll need to specify it doesn't need confirmation ahead of time. Lo and behold, it will automatically perform the download. So yes, it is technically possible, but good lord do it in a different way.

share|improve this answer
    
I know wget is a much better way, it's just a hypothetical question ;) Your answer comes pretty close, but still requires user intervention(clicking "Save", or configuring not to display this dialog) –  Robert Massa Oct 23 '09 at 15:15
2  
Like I said, you have to deselect the option to prompt to save for that file type. For example, download a zip file, disable that prompt, and then in the future any zip files accessed from the command line will automatically save. –  DHayes Oct 23 '09 at 15:17
1  
+1, though I've not validated it works (but the final statement is very true) –  Arjan Oct 23 '09 at 15:18
1  
+1 for "dear lord don't do it this way"... :) –  quack quixote Oct 23 '09 at 16:34

What like using 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 95, but certainly everything after that.

@RM: 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.

share|improve this answer
    
+1 good answer. ftp is pretty universal, as long as the server you're trying to download from supports it. –  DaveParillo Oct 23 '09 at 15:05
    
Thank you, sorry I wasn't more specific, I meant using HTTP. –  Robert Massa Oct 23 '09 at 15:10

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.

share|improve this answer
1  
this requires user interaction. probably not what most people who want to download a file from the command prompt want –  Kip Nov 14 '12 at 20:14

If you install Telnet, I imagine you could make a HTTP request to a server to download a file.

You can also install Cygwin, and use wget to download a file as well. This is a very easy way to download files from the command line.

share|improve this answer
2  
I'm pretty sure 'cygwin' counts as a non-standard utility ;-) –  DaveParillo Oct 23 '09 at 15:04
    
Telnet is an interesting option, is there a way to pipe the output to a file without corrupting it? And can we pipe HTTP GET command into telnet to make the request? –  Robert Massa Oct 23 '09 at 15:05
    
Install telnet? Telnet is like ftp; it comes with windows. Don't know about redirecting the output though. –  Satanicpuppy Oct 23 '09 at 15:10
    
For XP (as in the question) telnet is installed by default, but I heard that on Vista that's no longer the case? But no, it does not allow for file downloads, unless all is returned in a single HTTP response, and one can strip the headers and decode the stuff on the command line as well. Quite unlikely one can control that. –  Arjan Oct 23 '09 at 15:21
1  
Why install cygwin just to use wget? There is a native win32 binary available. –  innaM Oct 23 '09 at 15:39

There are a few ways that you can download using the command line in Windows:

  1. You can use Cygwin.

    Note: the included apps are not native Linux apps. You must rebuild your application from source if you want to run on Windows.

  2. Using telnet it's possible to make a request but you won't see any processing.

  3. You can write bat or VBS scripts.

  4. Write your own program that you can run from cmd.exe.

share|improve this answer

Use PowerShell like this:

  1. Create a download.ps1 file:

    param($url, $filename)
    $client = new-object System.Net.WebClient 
    $client.DownloadFile( $url, $filename)
    
  2. Now you can download a file like this:

    powershell Set-ExecutionPolicy Unrestricted
    powershell -ExecutionPolicy RemoteSigned -File "download.ps1" "http://somewhere.com/filename.ext" "d:\filename.ext"
    
share|improve this answer

You can install the Linux application Wget on Windows. It can be downloaded from http://gnuwin32.sourceforge.net/packages/wget.htm. You can then issue the command 'wget (inserturlhere)' or any other URL in your command prompt, and it will allow you to download that URL/file/image.

share|improve this answer
1  
Strangely this version is not always compatible. On my Windows 7 computer it wasn't because libraries were missing. You'd want to use wget without any extra libraries most of the time. users.ugent.be/~bpuype/wget –  sinni800 May 16 '11 at 12:17

Powershell (included with Windows 8 and included with .NET for earlier releases) has this capability. The powershell command allows running arbitrary Powershell commands from the command line or a .bat file. Thus, the following line is what's wanted:

powershell -command "& { (New-Object Net.WebClient).DownloadFile('http://example.com/', 'c:\somefile') }"
share|improve this answer
2  
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. –  harrymc May 29 at 11:45
1  
@harrymc sure it's an answer. it downloads a file. what more do you want? –  Janus Troelsen Jun 3 at 11:55
1  
(1) Some text to explain what does this one-liner, (2) Verify that your answer isn't an alternative formulation to a previous answer, since if it is, it should at most be expressed as a comment on that answer. –  harrymc Jun 3 at 12:34
    
What version of Windows and PowerShell is required for this to work? –  Peter Mortensen Jun 6 at 18:11

In default Windows, you can't download via HTTP. Windows is a GUI-centric OS, so it lacks many of the commandline tools you'd find in other OS's, like wget, which would be the prime candidate.

System.Net.WebClient.DownloadFile(), a function in the WiniNet API, can download files, but I'm not sure how far you're getting into actual development vs. a batch file.

share|improve this answer
    
I understand it's possible using wget, but my question states without the use non-standard windows utils. –  Robert Massa Oct 23 '09 at 15:09

If you have python installed here's an example which fetches the get-pip.py from the web

python -c "import urllib; urllib.urlretrieve ('https://bootstrap.pypa.io/get-pip.py', r'C:\python27\Tools\get-pip.py')"
share|improve this answer
    
Welcome to Super User, please take the Tour. Please read How do I write a good answer?. This is not an answer to the original question as the question asked Without using any non-standard (Windows included) utilities –  DavidPostill Aug 30 at 6:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.