9

I need to download a file through http from the command line on a windows server 2008. I am looking for something like wget, but it must be a built-in tool.

Is there such a tool?

2
  • Is PowerShell a built-in tool for you?
    – mailq
    Aug 15, 2011 at 8:16
  • Yes, PowerShell is ok. Aug 15, 2011 at 8:28

4 Answers 4

18

If you have PowerShell installed...

(New-Object System.Net.WebClient).DownloadFile("http://icanhazip.com/","icanhazip.txt")
3
  • 2
    Note for those not familiar with this call. The first argument is to the file to download, the second is what to save it as locally.
    – John
    Apr 11, 2012 at 14:43
  • 3
    For some reason this wouldn't work for me until I included the path in where to save it locally: (New-Object System.Net.WebClient).DownloadFile("http://download.microsoft.com/download/8/C/5/8C5EEDC7-3D72-4BB6-A55E-37F3977CD892/wpilauncher.exe","C:\wpilauncher.exe") Jun 27, 2013 at 17:45
  • Working over SSH is a problem as powershell does not start interactively inside the same terminal. I had to run powershell "your command with quotes escaped by a backslash" to make it work. May 2, 2017 at 16:31
1

you use curl also: http://curl.haxx.se/docs/manpage.html

something like

curl -O http://domain.com/file.gz

should work

1
  • 3
    curl is nice, but not built-in. Aug 15, 2011 at 8:52
0

No wget equivalent that is built-in/default across Windows.

0

I would liek to use the powershell way, however, when used to get at some pages, like those with erronous ssl code (self signed, or other) you need to set the expectations first before the call

[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$wc = New-Object System.Net.WebClient

$wc.DownloadFile ( "https://thesite.com/myPage", "LocalFileName.htm" )

This in turn will fail too, if it redirects to many times, f.ex. if it needs cookies to keep etc etc...

So sadly, without writing a small executable on my own there doesnt seem to be something besides wget that really can handle all situations so far... would love to be wrong.

1
  • If you need cookies, you are probably breaking ToS by downloading it via CLI anyway. Jul 4, 2013 at 13:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .