FIle download via cmd in windows using HTML

448 views Asked by At

I trying to download certain data from a site from cmd of windows. When I am downloading via this method, it is generating a firefox window and a pop up which I do not want. I should be downloaded to desired folder in background. I have created an index.HTML file in a directory.

<!DOCTYPE html>
 <html>
 <script>
 window.location.href = 'http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p50.pl?file=gfs.t06z.pgrb2full.0p50.f000&lev_10_m_above_ground=on&var_UGRD=on&var_VGRD=on&subregion=&leftlon=80.6&rightlon=85.4&toplat=25.6&bottomlat=20.1&dir=%2Fgfs.2015060606' ;
</script>
</html>

At cmd I am doing this "start index.HTML"

It is generating a firefox window and save popup which is asking for save permission. Is there any way I can do that more smoothly in the background.So that the window doesn't come.

2

There are 2 answers

0
Verbatus On

If you are using Windows and Internet Explorer, you can write a VBScript. It can be executed from the command line or just be embed in HTML documents. You can search stack exchange for some useful VBScripts expamples.

0
BufferOverflow On

Why do you not use PowerShell? I don't have access to a Windows machine at the moment, but this should work.

$localFile = "C:\Users\<Username>\Downloads\index.html"
$webClient = New-Object System.Net.WebClient
$urlAddress = "http://example.com/index.html"
$webclient.DownloadFile($url,$localFile)

This will download the data that stored at $urlAddress and store it in $localFile.