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.

And I mean without using any non-standard(Windows included) utilities. 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
show 1 more comment

11 Answers

up vote 27 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
    
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
add comment

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
    
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
9  
it is part of windows7. –  akira Aug 20 '11 at 4:20
1  
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
2  
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
show 2 more comments

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
10  
(New-Object Net.WebClient).DownloadFile('someurl', 'somepath') –  Jason Stangroome Nov 17 '11 at 2:52
2  
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
add comment

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 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
add comment

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
add comment

Windows Explorer can download files via http. Just enter the URL into the Address bar. Or from the command line, eg: 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 save it.

I just tested this on my vmware image of a virgin install of WinXP 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
add comment

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
1  
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
show 2 more comments

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
add comment

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
add comment

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
add comment

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
add comment

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.