474

How can I download something from the web directly without Internet Explorer or Firefox opening Acrobat Reader/Quicktime/MS Word/whatever?

I'm using Windows, so a Windows version of Wget would do.

SDsolar
  • 1,578
  • 3
  • 18
  • 30
Paolo Tedesco
  • 1,549
  • 4
  • 12
  • 15
  • Just right clicking a file and hitting "Save Target As" or "Save Link As" or "Save As" (language varies depending on your browser) will work. – BrainSlugs83 Oct 22 '12 at 05:53
  • 28
    The point of having a command is being able to write a batch file and run it (perhaps scheduled as a task) anytime you want. That's where the GUI falls short. – Jbm Nov 15 '12 at 14:11
  • 7
    How do you download with MS Word? – Jaime Hablutzel Aug 20 '14 at 12:16
  • 7
    @JaimeHablutzel Why would you ever want to download something via MS Word? MS Word is not a terminal. – Braden Best May 14 '15 at 20:53
  • @B1KMusic look at the original question, I was having the same doubt as you – Jaime Hablutzel May 15 '15 at 00:28
  • if a popup dialog for destination/open is ok that comes from the "auto-open-closed" Internet Explorer you could use `"%programfiles%/Internet Explorer/iexplore.exe" http://foo.bar/somefile` (should work on many systems) – Andreas Covidiot May 23 '16 at 06:44
  • It's 2016 - make sure you scroll down to the answers that say "Powershell". (Exactly the built-in solution you want when you're IE-restricted and you're trying to avoid installing random stuff on a client's servers...) – mwardm Sep 07 '16 at 16:22
  • Here is a good article on using curl in PowerShell: http://thesociablegeek.com/azure/using-curl-in-powershell/ – SDsolar Oct 16 '17 at 03:12
  • 1
    @SDsolar Or just upvote/improve [this answer](https://superuser.com/questions/25538/how-to-download-files-from-command-line-in-windows-like-wget-is-doing/494009#494009) below. – Franklin Yu Nov 13 '17 at 19:32
  • Roger that. I did so, with complete instructions that will work with any modern version of Windows - no additions or modifications are required. – SDsolar Nov 15 '17 at 18:43

21 Answers21

379

An alternative I discovered recently, using PowerShell:

$client = new-object System.Net.WebClient
$client.DownloadFile("http://www.xyz.net/file.txt","C:\tmp\file.txt")

It works as well with GET queries.

If you need to specify credentials to download the file, add the following line in between:

$client.Credentials =  Get-Credential                

A standard windows credentials prompt will pop up. The credentials you enter there will be used to download the file. You only need to do this once for all the time you will be using the $client object.

Paolo Tedesco
  • 1,549
  • 4
  • 12
  • 15
  • 109
    You can also do it in one-line: `(new-object System.Net.WebClient).DownloadFile('http://www.xyz.net/file.txt','C:\tmp\file.txt')` – schellack Oct 14 '11 at 20:32
  • That would be nothing like wget at all if only for the fact you have to install another large program just to use it. – Rob Dec 14 '12 at 03:07
  • 16
    @Rob powershell is built in to Windows... – nhinkle Dec 14 '12 at 04:22
  • 10
    From Vista up, yes. – Arran Dec 19 '12 at 12:44
  • 1
    Re @Arran: "From Vista up, yes" -- so... for the last six years (going on 7 now), yes, this has been built into Windows. – BrainSlugs83 May 07 '13 at 02:40
  • 3
    @BrainSlugs83, absolutely, but many, *many*, people are still using XP. It's merely something to bear in mind. – Arran May 07 '13 at 08:08
  • 4
    @BrainSlugs83, you underestimate the amount of people still on older Windows systems. I don't understand the issue, I pointed out it's only on Vista upwards. People can choose to ignore it, or say "hey thanks!", but you....? If you have an issue, create a chat and we can talk. Someone with rep (like you) should realise *here* is not the place for this discussion. – Arran Jun 04 '13 at 21:17
  • 2
    I'm just pointing out the clarification is a bit silly as it's been built into windows as long as it has existed -- and all currently supported versions of Windows have it built in. Nothing further. – BrainSlugs83 Jun 07 '13 at 03:12
  • What if you need authentication for an https site AND you are behind a proxy? – opticyclic Nov 26 '14 at 19:10
  • Is there an option to see the progress of the download? – Devesh Khandelwal Dec 12 '15 at 20:08
  • 3
    I'm not sure if this changed in some version of Powershell, but you can not specify a path for the second parameter of DownloadFile (you can only specify a filename). So if the above doesnt work for you, try: `(new-object System.Net.WebClient).DownloadFile('http://www.example.net/file.‌​txt','file.tx‌​t')` – n00b Dec 15 '17 at 02:07
  • 1
    Wget is build into powershell, useless. – Pedro Lobito Oct 28 '18 at 19:47
  • // , To my surprise, wget is built into PowerShell. But I'm pretty sure it doesn't work the same as in Linux. – Nathan Basanese Oct 30 '18 at 18:50
  • 1
    `wget` in PowerShell is an alias for `Invoke-WebRequest`. Try running `Get-Alias wget`... – Paolo Tedesco Oct 31 '18 at 10:19
  • baby this is what I came for – Thecarisma May 06 '19 at 08:25
  • 1
    Simpy use in PowerShell `wget https://myurl.com -OutFile myurl-result.html` – Ton Snoei Feb 11 '20 at 07:25
  • @BrainSlugs83: almost no one is using Win XP; almost everyone have migrated either to Win 10 or Ubuntu – Zimba Mar 09 '21 at 05:07
219

Wget for Windows should work.

From the Wget Wiki FAQ:

GNU Wget is a free network utility to retrieve files from the World Wide Web using HTTP and FTP, the two most widely used Internet protocols. It works non-interactively, thus enabling work in the background, after having logged off.

From this section of FAQ, download links are suggested:

Windows Binaries

Link with courtesy of Jernej Simončič is used instead.

Tony
  • 1,156
  • 1
  • 9
  • 13
  • 9
    There's also Winwget http://www.cybershade.us/winwget/ if you prefer a gui – Col Aug 19 '09 at 11:47
  • 14
    The standalone version is downloadable from [this link](http://users.ugent.be/~bpuype/wget/). – Vito Gentile Feb 24 '14 at 11:19
  • 6
    More recent, even up-to-date (as of today) [Windows builds](https://eternallybored.org/misc/wget/), provided by Jernej Simončič – Gras Double Feb 16 '15 at 19:37
  • @VitoShadow broken link – Nate Anderson Jun 14 '15 at 15:09
  • Sorry, [can no longer trust source forge downloads](http://www.infoworld.com/article/2929732/open-source-software/sourceforge-commits-reputational-suicide.html) – cixelsyd Nov 13 '15 at 18:14
  • 1
    @cixelsyd Updated link to alternative source. –  Nov 21 '15 at 11:11
  • https://web.archive.org/web/20150115044318/http://users.ugent.be/~bpuype/wget – undo Jan 10 '16 at 14:09
  • `wget https://unsecure-cert-site.com/page.html --no-check-certificate -O outputfile.html` to get around https issues. – kayleeFrye_onDeck Nov 15 '16 at 05:33
  • 1
    There is no need to download anything. See https://superuser.com/questions/25538/how-to-download-files-from-command-line-in-windows-like-wget-is-doing/494009#494009 below for instructions on how to make this work in native PowerShell. – SDsolar Nov 15 '17 at 18:44
  • 2
    eternallybored.org/misc/wget/ is flagged by enterprise antivirus on my system. Carbon Black / Bit 9. Probably false positive. But sourceforge one runs. Does not support sslv3. – TamusJRoyce Jan 12 '18 at 05:22
  • sorry, but it is slower than google chrome download it downloads 200MB file in 9min and does the same with chrome in2 min ;) – Bhavesh Prajapati Dec 19 '20 at 12:43
  • 1
    how I wget the wget command if I don't have wget on my windows ? – JOduMonT Jun 07 '21 at 13:36
  • https://www.virustotal.com/gui/file/e8fbec25db4f9d95b5e8f41cca51a4b32be8674a4dea7a45b6f7aeb22dbc38db/community – z3nth10n Aug 17 '21 at 20:07
193

cURL

Windows 10 includes curl.exe:

https://techcommunity.microsoft.com/t5/containers/-/ba-p/382409

so you can do something like this:

# example 1
curl.exe --output index.html --url https://superuser.com
# example 2
curl.exe -o index.html https://superuser.com

If you have older Windows, you can still download it:

https://curl.haxx.se/windows

PowerShell

# example 1
Invoke-WebRequest -OutFile index.html -Uri https://superuser.com
# example 2
iwr -outf index.html https://superuser.com

https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest

Zombo
  • 1
  • 24
  • 120
  • 163
  • This doesn't work with redirects on sourceforge (and possibly other sites), as opposed to `System.Net.WebClient`. However you can make `Invoke-WebRequest` work by adding `-UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox`. – Ela782 Jan 07 '16 at 12:22
  • The powershell part is the only one working in Server 2016 core mode. Note that you need to specify the `securityprotocol` like https://stackoverflow.com/a/48030563/350580 to make https acturally work – Ding-Yi Chen Sep 28 '20 at 06:34
78

It's possible to download a file with certutil:

certutil.exe -urlcache -split -f "https://download.sysinternals.com/files/PSTools.zip" pstools.zip

Certutil is not installed by default on XP/Win2003 but is avaialble on the newer windows versions.For XP/2003 you'll need the Admin Tool Pack for windows server 2003


Old answer:

Windows has its own command line download utility - BITSAdmin:

BITSAdmin is a command-line tool that you can use to create download or upload jobs and monitor their progress.

Here's my overview of how a file can be downloaded on windows without external tools

And a complete bitsadmin example:

bitsadmin /transfer myDownloadJob /download /priority normal http://downloadsrv/10mb.zip c:\10mb.zip
Thomas Weller
  • 5,704
  • 11
  • 55
  • 100
npocmaka
  • 1,259
  • 12
  • 12
  • 8
    Interesting. That is one clumsy piece of software compared to wget. – hookenz Mar 28 '12 at 21:36
  • 2
    Note that It doesn't ship with Windows XP, and maybe not with other versions either. – Ian Dunn May 22 '12 at 23:06
  • 12
    Update: 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. – nulldev07 Sep 28 '12 at 05:49
  • 2
    @MattH: because it's nto suppsoed to be wget in the first place? - see http://en.wikipedia.org/wiki/Background_Intelligent_Transfer_Service – peterchen Sep 27 '13 at 12:17
  • 4
    Unable to add file - 0x80070057 – Tomáš Zato Apr 26 '16 at 17:55
  • Thank you for providing a native solution. Obviously wget is "like" wget... – p_q Sep 12 '18 at 00:29
  • 1
    I think you can not use relative paths, fx "foo.zip", you must use absolute paths like "C:\Users\jdoe\foo.zip". Otherwise you get "Unable to add file - 0x80070057 - The parameter is incorrect". – Mads Skjern Oct 02 '18 at 08:12
  • 1
    @MadsSkjern - yes with bitsadmin you cannot use relative paths. One workarround is to add `%cd%` to target location if you want to be relative to the current location. – npocmaka Oct 02 '18 at 09:28
  • On Windows 10, using certutil to download files sometimes causes Defender to block it as a Trojan:Win32/Ceprolad.A – JustAMartin Nov 15 '22 at 09:59
39

Save the following text as wget.js and simply call

cscript /nologo wget.js http://example.com

This is the code:

var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
WinHttpReq.Open("GET", WScript.Arguments(0), /*async=*/false);
WinHttpReq.Send();
WScript.Echo(WinHttpReq.ResponseText);

/* To save a binary file use this code instead of previous line
BinStream = new ActiveXObject("ADODB.Stream");
BinStream.Type = 1;
BinStream.Open();
BinStream.Write(WinHttpReq.ResponseBody);
BinStream.SaveToFile("out.bin");
*/
slhck
  • 223,558
  • 70
  • 607
  • 592
user190042
  • 51
  • 2
  • 3
26

There is a native cURL for Windows available here. There are many flavors available- with and without SSL support.

You don't need the extra baggage of Cygwin and the likes, just one small EXE file.


It is also important to know that there are both wget and curl aliases built into all modern versions of Windows Powershell. They are equivalent.

No extra files or downloads are required to obtain wget functionality:

Using Curl In Powershell (The Sociable Geek)

Excerpt:

You can type in a cURL command like one that downloads a file from a GitHub repository.

curl http://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/mongodb-on-ubuntu/azuredeploy.json

and it will seem like it works but what it is actually doing is just using cURL as an alias. In the above instance, what will happen is that you will just get the headers instead of the file itself.

Aliases in PowerShell allow you to create shortcuts for longer commands so you don’t have to type them out all of the time.

If you type in the command Get-Alias, it will give you a list of all the Aliases that are used in PowerShell. As you can see, the curl command just calls the Invoke-WebRequest command. They are similar but not the same which is why the above request does not work for us.

enter image description here

To get this to work properly in PowerShell the easiest way is to use variables and the -OutFile argument as shown here:

enter image description here

(file name cut off in image “https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/mongodb-on-ubuntu/azuredeploy.json”)

This syntax will download the full contents of the target file azuredeploy.json to the local file newfile.json


The primary advantage is that it is built into Powershell itself so this code will execute directly with no downloads or any other extra file creations are required to make it work on any modern version of Windows.

SDsolar
  • 1,578
  • 3
  • 18
  • 30
Gaurav Kumar
  • 324
  • 4
  • 7
  • This be done directly on one line, but the line gets pretty long and is not as immediately readable at a glance. – SDsolar Nov 15 '17 at 18:48
25

I made a quick myGet.bat file which calls the PowerShell method described above.

@Echo OFF
SetLocal EnableDelayedExpansion
Set Var=%1
Set Var=!Var:http://=!
Set Var=!Var:/=,!
Set Var=!Var:%%20=?!
Set Var=!Var: =?!
Call :LOOP !var!
Echo.Downloading: %1 to %~p0!FN!
powershell.exe -Command (new-object System.Net.WebClient).DownloadFile('%1','%~p0!FN!')
GoTo :EOF
:LOOP
If "%1"=="" GoTo :EOF
Set FN=%1
Set FN=!FN:?= !
Shift
GoTo :LOOP

I borrowed some code from Parsing URL for filename with space.

Matti Wens
  • 101
  • 4
MartinC
  • 171
  • 2
  • 3
  • 1
    why the downvote? this looks okay to me and is a direct response to the question. Yes it's clunky and could use improvement, like escaping ampersands (&) in the url, but it works as is. – matt wilkie Apr 24 '13 at 05:02
  • Wouldn't it be easier to just write a PowerShell script??? – SamB Feb 26 '19 at 23:12
  • 4
    `powershell.exe -Command "Invoke-WebRequest -OutFile ./file-name https://location/file-name"` <-- Simple one line powershell usage in script file hard coding location and file name. – James Eby Jun 20 '19 at 20:58
9

You could also use the wget packaged in PowerShell. ;^) To open, hit the Windows key and type "powershell" or Windows-R and type "powershell" and hit return.

No installation necessary.

One interesting difference from conventional wget (more at that link): You can't simply use the greater-than to pipe to a file. wget in PowerShell is just a convenience wrapper for Invoke-WebRequest, and you need to use its syntax to write to a file.

wget https://superuser.com/questions/25538 -OutFile rubySlippers.html
ruffin
  • 1,825
  • 1
  • 14
  • 17
9

I was searching for the same, and since I had no privilege to install any of the above packages, I went for a small workaround (to download 30+files):

  • I created a batch file
  • Listed all the files
  • Put firefox.exe at the beginning of each line
  • Went to the firefox directory in Program Files
  • Ran it.
Peter Mortensen
  • 12,090
  • 23
  • 70
  • 90
Jesse P Francis
  • 151
  • 2
  • 11
7

If PowerShell is an option, that's the preferred route, since you (potentially) won't have to install anything extra:

(new-object System.Net.WebClient).DownloadFile('http://www.example.com/file.txt', 'C:\tmp\file.txt')

Failing that, Wget for Windows, as others have pointed out is definitely the second best option. As posted in another answer it looks like you can download Wget all by itself, or you can grab it as a part of Cygwin or MSys.

If for some reason, you find yourself stuck in a time warp, using a machine that doesn't have PowerShell and you have zero access to a working web browser (that is, Internet Explorer is the only browser on the system, and its settings are corrupt), and your file is on an FTP site (as opposed to HTTP):

start->run "FTP", press "OK".

If memory serves it's been there since Windows 98, and I can confirm that it is still there in Windows 8 RTM (you might have to go into appwiz.cpl and add/remove features to get it). This utility can both download and upload files to/from FTP sites on the web. It can also be used in scripts to automate either operation.

This tool being built-in has been a real life saver for me in the past, especially in the days of ftp.cdrom.com -- I downloaded Firefox that way once, on a completely broken machine that had only a dial-up Internet connection (back when sneakernet's maximum packet size was still 1.44 MB, and Firefox was still called "Netscape" /me does trollface).

A couple of tips: it's its own command processor, and it has its own syntax. Try typing "help". All FTP sites require a username and password; but if they allow "anonymous" users, the username is "anonymous" and the password is your email address (you can make one up if you don't want to be tracked, but usually there is some kind of logic to make sure it's a valid email address).

David
  • 101
  • 3
BrainSlugs83
  • 124
  • 2
  • 6
  • +1 for thinking of command line ftp! However wget and powershell were both mentioned well before you joined the party, so -1 there. :-/ – matt wilkie Apr 24 '13 at 05:08
  • The other powershell answers I saw were all multi-liners and/or had some code smell to them -- this is a short & simple one liner to download a file. -- Also I wanted to provide an answer that covered all the bases. :-) – BrainSlugs83 Jan 12 '16 at 00:20
6

Search for /download function on https://lolbas-project.github.io.

Right now there are Bitsadmin.exe, Certutil.exe, Esentutl.exe, Expand.exe, Extrac32.exe, Findstr.exe, Hh.exe, Ieexec.exe, Makecab.exe, Replace.exe for Windows vista, Windows 7, Windows 8, Windows 8.1, Windows 10 and the equivalent Server versions.

noraj
  • 376
  • 1
  • 4
  • 15
4

On Win CMD (if you have write access):

set url=https://www.nsa.org/content/hl-images/2017/02/09/NSA.jpg
set file=file.jpg
certutil -urlcache -split -f %url% %file%
echo Done.

Built in Windows app. No need for external downloads.

Tested on Win 10

Zimba
  • 1,051
  • 11
  • 15
4

Cygwin has Wget (and many more utilities).

Peter Mortensen
  • 12,090
  • 23
  • 70
  • 90
Rich Homolka
  • 31,057
  • 6
  • 55
  • 80
3

In Windows one can also use a Linux Terminal Emulator, like MobaXterm, or WSL2.

The procedure is similar for both, what varies is the installation process.

For MobaXterm, this is the proceedure:

  1. Download and Install MobaXterm (the Home Edition may be enough for your use case).

  2. Access MobApt (MobaXterm package manager) by opening the terminal and run MobApt.

Access MobApt package manager

  1. Find the package wget and press Install/Update (assuming that it is still not installed).

MobApt package manager for MobaXterm

  1. Then, run your script (I will leave at the bottom an example of a wget script that you may run).

For WSL2, this is the procedure:

  1. Install WSL2 (https://docs.microsoft.com/en-us/windows/wsl/install-win10). I'm using Ubuntu 18.

  2. Once the setup is done, open and run the following command:

sudo apt-get install wget

  1. Then run your script (I will leave at the bottom an example of a wget script that you may run).

You may use this script in both cases:

wget --header='Accept-Language: en-US,en;q=0.9,pt-PT;q=0.8,pt;q=0.7,de;q=0.6,fr;q=0.5,es;q=0.4,it;q=0.3,gl;q=0.2,hu;q=0.1' --user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36" -c "http://..." -w 1
Gonçalo Peres
  • 741
  • 3
  • 12
  • 25
2

I think installing wget via Chocolatey is the easiest way.

  1. Install Chocolatey
  2. From the command-line, type: choco install wget
  3. You can then use wget from the command line like on *nix systems.
sivabudh
  • 3,095
  • 7
  • 28
  • 30
2

And http://www.httrack.com/ has a nice GUI (and it's free), for mirroring sites. It also has a Linux version.

Peter Mortensen
  • 12,090
  • 23
  • 70
  • 90
Zsolt Botykai
  • 697
  • 1
  • 7
  • 16
1

As documented in this SU answer, you can use the following in Powershell:

Import-Module bitstransfer
start-bitstransfer -source http://something/something.ext -destination c:\something.ext
Dolan Antenucci
  • 377
  • 2
  • 4
  • 14
1

You can get WGet for Windows here. Alternatively you can right click on the download link of the item you want to download and choose Save As. This will download the file and not open it in the assigned application.

BinaryMisfit
  • 20,643
  • 10
  • 67
  • 76
1

If you want a GUI, then try VisualWget, which is actually clean, and feature full. It is based on GNU Wget for its download engine.

EDIT: updated link.

Wurlitzer
  • 19
  • 3
  • 1
    here is an updated link: https://sites.google.com/site/visualwget/a-download-manager-gui-based-on-wget-for-windows (the downloads are at the bottom of the page, use the little arrows on the right) – Reed Hedges May 13 '12 at 12:43
0

An alternative to using gnuwin32 is unxutils which includes wget.

Chris Chilvers
  • 257
  • 1
  • 2
  • 8
  • you can manage with unxutils but it's old, it uses an old version of wget. gnuwin32 is the thing to use. not quite as convenient to install and not as easy to find things, but it has much more than unxutils too. – barlop Oct 05 '11 at 19:31
-2

If you need a visual Post for Windows, here is one.
You can post data or files with it.

Gabriel
  • 2,059
  • 7
  • 32
  • 49