Run cURL commands from Windows console

327,860

Solution 1

Download cURL for Windows from here (and be sure to select it from Win32 - Generic way down on the page).

Then place it in a directory inside your PATH environment variable (ie: C:\Windows\System32) or run it with its full path preceding the executable name.

If you place it in a directory that's inside your PATH, make sure to close and then reopen command prompt to make the command available.

Solution 2

If you install Git for Windows you get Curl automatically too. There are some advantages:

  • Git takes care of the PATH setup during installation automatically.
  • You get the GNU bash, a really powerful shell, in my opinion much better than the native Windows console.
  • You get many other useful Linux tools like tail, cat, grep, gzip, pdftotext, less, sort, tar, vim and even Perl.

enter image description here

Solution 3

After installing OpenSSL Light, restart Windows, open Command Prompt, then do a test command like:

curl http://www.google.com

If you get HTML tags back, it worked.

Solution 4

How to setup cURL:

  • Download and unzip 64-bit cURL with SSL.
  • Copy the curl.exe file into your Windows PATH folder. By default, this is C:\Windows\System32.
  • Download and install the Visual Studio 2010 C++ Runtime Redistributable 64 bit here.
  • Download the latest bundle of Certficate Authority Public Keys from mozilla.org here.
  • Rename this file from cacert.pem to curl-ca-bundle.crt.
  • Move this file into your Windows PATH folder.

How to test it:

  • Run cmd.exe to open your command prompt.
  • For both commands, you should see a couple pages of the HTML source code. If you see this, cURL is up and running!

Solution 5

For folks that don't literally need the curl executable, but rather just need to e.g. see or save the results of a GET request, can use powershell directly. From a normal command prompt, type:

powershell -Command "(new-object net.webclient).DownloadString('http://example.com')"

which, while a bit wordy, is similar to typing

curl http://example.com/

in a more Unix-ish environment.

More information about net.webclient is available here: WebClient Methods (System.Net).

Share:
327,860

Related videos on Youtube

user3469203
Author by

user3469203

Electrical Engineering (telecommunications specialist) & Programmer, IT entrepreneur.

Updated on September 18, 2022

Comments

  • user3469203
    user3469203 almost 2 years

    Is there a way to install cURL in windows in order to run cURL commands from the command prompt?

    • phuclv
      phuclv almost 6 years
      I'm voting to close this question as off-topic because it was cross-posted on SO
  • Eltariel
    Eltariel about 12 years
    You don't need to reopen the console if you put it in a directory on the path, you only need to do that if you change the PATH variable.
  • CAD bloke
    CAD bloke over 11 years
    One hard reboot later because I couldn't kill the task - um, you might wanna be careful with this.
  • pedrommuller
    pedrommuller about 10 years
    worked like a charm!
  • CodyBugstein
    CodyBugstein over 9 years
    Related; can you also install libraries for https?
  • cchamberlain
    cchamberlain about 9 years
    This is probably the best all around solution since git is useful for many of the things that curl does but source wise.
  • Diode Dan
    Diode Dan almost 7 years
    If you have Git, this is a great solution
  • Armfoot
    Armfoot over 6 years
    Exactly what I was looking for! I actually used the DownloadFile method: powershell -Command "(new-object net.webclient).DownloadFile('http://.../somefile', 'file.txt')". You also just taught me how to use the PowerShell without opening its prompt. Thank you matty!
  • dev0
    dev0 over 6 years
    Newer versions of git-for-windows do not come with curl in the path, you have to run /mingw64/bin/curl.