Run cURL commands from Windows console

965,783

Solution 1

If you are not into Cygwin, you can use native Windows builds. Some are here: curl Download Wizard.

Solution 2

First you need to download the cURL executable. For Windows 64bit, download it from here and for Windows 32bit download from here After that, save the curl.exe file on your C: drive.

To use it, just open the command prompt and type in:

C:\curl http://someurl.com

Solution 3

If you have Git installed on windows you can use the GNU Bash.... it's built in.

https://superuser.com/questions/134685/run-curl-commands-from-windows-console/#483964

Solution 4

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 now and again, 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).

UPDATE: I like how ImranHafeez took this one step further in this answer. I'd prefer a simpler cmd-script however, maybe creating a curl.cmd file containing this:

@powershell -Command "(new-object net.webclient).DownloadString('%1')"

which could be called just like the Unix-ish example above:

curl http://example.com/

Solution 5

If you use the Chocolatey package manager, you can install cURL by running this command from the command line or from PowerShell:

choco install curl
Share:
965,783
DomingoSL
Author by

DomingoSL

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

Updated on July 08, 2022

Comments

  • DomingoSL
    DomingoSL almost 2 years

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

  • Adrian Carr
    Adrian Carr almost 10 years
    Heck yeah that helped. Very easy. Thanks for posting.
  • BRogers
    BRogers almost 10 years
    This means that you would run it just like you would from OSX or Linux without using special commands btw. Just start the Git Bash and cURL away :)
  • BigRon
    BigRon over 8 years
    This answer needs more upvotes. This is the way to go for users comfortable with mac terminal or unix distributions.
  • BRogers
    BRogers over 7 years
    Thank you :) since I use Git primarily anyway (regardless of the OS I'm using) I need the Git Bash installed. I don't like installing wizards or extra bloat. I'm also not a big fan of trying to use PowerShell to do everything in windows
  • DPM
    DPM almost 7 years
    Also msys2, which I didn't see mentioned yet. You might have it already if you installed Haskell at some point for example.
  • Max
    Max over 6 years
    Credentials may be given powershell -Command "$wc=new-object net.webclient;$wc.Credentials=new-object System.Net.NetworkCredential(%user%,%pass%);$wc.DownloadStri‌​ng('%input%')" from stackoverflow.com/a/509394/4985705
  • BRogers
    BRogers over 6 years
    You can install Git and use the git bash. Built-in after install. (see answer below).
  • Nico Haase
    Nico Haase over 6 years
    Why do you need that if there a multiple answers with a more simple approach?
  • ΩmegaMan
    ΩmegaMan about 6 years
    @NicoHaase Just because an answer is different does not make it necessarily wrong. SO should be about answers, not just what the crowd believes is only the best answer...sometimes it is not. I used this and gave it a +1 because it is the current way to install it.
  • Francis Cugler
    Francis Cugler about 6 years
    @NicoHaase If you are located at point A on a triangle and points B & C are the same distance from point A. You instruct someone to randomly travel to either point B or C first then to travel back to point A but not from the same path you just previously traveled from. Which answer is correct: ABCA or ACBA? As you can see there are more than one valid answers and both are worth the same in the course or path that was taken!
  • Francis Cugler
    Francis Cugler about 6 years
    You can do more than that if the appropriate binaries are in the Cygwin/bin directory! You can even call gcc's compiler options, make, zip, lynx, etc. There are some limitations though, and you would probably want to run windows cmd being elevated to admin privileges, then navigate to your Cygwin or Cygwin64 directory within command prompt then call the Cygwin batch file. However make sure that in your system's property for environment variables under path you set the path to Cygwin64/bin/. Now you can use Unix binaries to run within cmd.
  • chomp
    chomp about 6 years
    It's really important to use " instead of ' if you are going to do it in Windows :)
  • Stephen R
    Stephen R about 5 years
    WARNING: This does NOT pass GET parameters to the page. I used this with a PHP page. curl https://www.example.com/mypage.php?action=hello. In the mypage.php script, $_GET['action'] is empty
  • wisbucky
    wisbucky almost 5 years
    this is a duplicate of this answer: stackoverflow.com/questions/2710748/…
  • gek
    gek over 4 years
    so how to call git-bash-curl directly from cmd/powershell?
  • gek
    gek over 4 years
    so how to call git-bash-curl directly from cmd/powershell?
  • easrng
    easrng about 4 years
    This had the answer I was looking for hidden in plain sight! iex (new-object net.webclient).downloadstring('https://a.url.here') to download and run a PS script was just what I needed.
  • Jojo
    Jojo over 3 years
    This is outdated, see answer stackoverflow.com/a/61384072/4385330 . In newer windows versions the curl command is available in PowerShell
  • Kms
    Kms about 3 years
    @Ricardo Sanchez , can we pass number of request call per second ? My Requirement is I need to hit URL 5 times in each second in windows OS.
  • matty
    matty over 2 years
    Modern windows installations have curl built in now. Try that before trying to implement it via powershell.