Run cURL commands from Windows console
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
DomingoSL
Electrical Engineering (telecommunications specialist) & Programmer, IT entrepreneur.
Updated on July 08, 2022Comments
-
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 almost 10 yearsHeck yeah that helped. Very easy. Thanks for posting.
-
BRogers almost 10 yearsThis 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 over 8 yearsThis answer needs more upvotes. This is the way to go for users comfortable with mac terminal or unix distributions.
-
BRogers over 7 yearsThank 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 almost 7 yearsAlso msys2, which I didn't see mentioned yet. You might have it already if you installed Haskell at some point for example.
-
Max over 6 yearsCredentials may be given
powershell -Command "$wc=new-object net.webclient;$wc.Credentials=new-object System.Net.NetworkCredential(%user%,%pass%);$wc.DownloadString('%input%')"
from stackoverflow.com/a/509394/4985705 -
BRogers over 6 yearsYou can install
Git
and use the git bash. Built-in after install. (see answer below). -
Nico Haase over 6 yearsWhy do you need that if there a multiple answers with a more simple approach?
-
Ω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 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 about 6 yearsYou 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 about 6 yearsIt's really important to use " instead of ' if you are going to do it in Windows :)
-
Stephen R about 5 yearsWARNING: 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 almost 5 yearsthis is a duplicate of this answer: stackoverflow.com/questions/2710748/…
-
gek over 4 yearsso how to call git-bash-curl directly from cmd/powershell?
-
gek over 4 yearsso how to call git-bash-curl directly from cmd/powershell?
-
easrng about 4 yearsThis 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 over 3 yearsThis is outdated, see answer stackoverflow.com/a/61384072/4385330 . In newer windows versions the curl command is available in PowerShell
-
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 over 2 yearsModern windows installations have curl built in now. Try that before trying to implement it via powershell.