How to download files from command line in Windows like wget or curl

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.


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

  • courtesy of Jernej Simončič: http://eternallybored.org/misc/wget/

  • from sourceforge: http://gnuwin32.sourceforge.net/packages/wget.htm

  • [...]

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


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

Tags:

Windows

Curl

Wget