2

I am very new to cmd prompt and I was asked to find out how to script cmd to pull files from a website.

Honestly, I am totally at a loss, so any help would help me escalate the project I am working on.

Currently, I am using this script to go to the website but, but I am probably making some kind of mistake. I am on Windows 7.

@echo Off
TITLE Download Treasury Files
Pause
CD C:\Users\wkhan\desktop
START http://www.treasury.gov/ofac/downloads/t11sdn.pdf
slhck
  • 223,558
  • 70
  • 607
  • 592
Vaz
  • 33
  • 1
  • 1
  • 3
  • Possible duplicate of [Is it possible to download using the Windows command line?](http://superuser.com/questions/59465/is-it-possible-to-download-using-the-windows-command-line), [Download a file via HTTP from a script in Windows](http://superuser.com/questions/129269/download-a-file-via-http-from-a-script-in-windows), [What is the Windows equivalent of Wget?](http://superuser.com/questions/25538/what-is-the-windows-equivalent-of-wget) – and31415 May 12 '14 at 14:43

1 Answers1

1

I think there is no built in tool in Windows that would do that for you. But there are plenty free programs on the web, that you can install and then call from your batch script. Here is one of them: CURL

Here is a basic example of how to use it (using your link)

@echo Off
TITLE Download Treasury Files
Pause
CD C:\Users\wkhan\desktop
curl http://www.treasury.gov/ofac/downloads/t11sdn.pdf > download.pdf

This would download and save the file from the URL you have provided to download.pdf

Another possible alternative would be WGET.

UPDATE:

From Windows 10 build 17063 and later, ‘Curl’ is now included, so that you can execute it directly from Cmd.exe or PowerShell.exe

source: https://superuser.com/a/1584434/281154

Art Gertner
  • 7,149
  • 11
  • 42
  • 72
  • 1
    when I try to install CURL this is the error msg: "the program cant start because libssl32.dll is missing from your computer. try reinstalling the program to fix this problem. – Vaz May 12 '14 at 14:37
  • I got that same error with wget and it used to work. It must be something with the environment settings... – David Brossard Dec 21 '15 at 22:54
  • 1
    As suggested [here](https://superuser.com/questions/59465/is-it-possible-to-download-using-the-windows-command-line#1584434), `curl` seems to be preinstalled now - yay!' – Janaka Bandara Jan 18 '21 at 02:55