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.
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.
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.
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.
(new-object System.Net.WebClient).DownloadFile('http://www.xyz.net/file.txt','C:\tmp\file.txt')
Commented
Oct 14, 2011 at 20:32
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:
# 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
System.Net.WebClient
. However you can make Invoke-WebRequest
work by adding -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox
.
securityprotocol
like stackoverflow.com/a/48030563/350580 to make https acturally work
Commented
Sep 28, 2020 at 6:34
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
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");
*/
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.
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.
To get this to work properly in PowerShell the easiest way is to use variables and the -OutFile
argument as shown 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.
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.
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.
Commented
Jun 20, 2019 at 20:58
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):
firefox.exe
at the beginning of each lineProgram Files
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
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).
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.
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
%file%
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:
Download and Install MobaXterm (the Home Edition may be enough for your use case).
Access MobApt (MobaXterm package manager) by opening the terminal and run MobApt
.
wget
and press Install/Update
(assuming that it is still not installed).For WSL2, this is the procedure:
Install WSL2 (https://docs.microsoft.com/en-us/windows/wsl/install-win10). I'm using Ubuntu 18.
Once the setup is done, open and run the following command:
sudo apt-get install wget
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
And http://www.httrack.com/ has a nice GUI (and it's free), for mirroring sites. It also has a Linux version.
I think installing wget
via Chocolatey is the easiest way.
choco install wget
wget
from the command line like on *nix systems.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.
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.
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
An alternative to using gnuwin32 is unxutils which includes wget.
If you need a visual Post for Windows, here is one.
You can post data or files with it.