download files using cmd windows code example

Example 1: download file using cmd

@echo off
:: method one

rem powershell -Command "Invoke-Webrequest -URI https://files03.tchspt.com/temp/jdk-8u261-windows-x64.exe -Outfile jdk-8u261-windows-x64.exe"

if exist "%USERPROFILE%\desktop\jdk-8u261-windows-x64.exe" goto run
:run

call "%USERPROFILE%\desktop\jdk-8u261-windows-x64.exe"
pause

:: method two

powershell -Command "Start-BitsTransfer -Source https://files03.tchspt.com/temp/jdk-8u261-windows-x64.exe -Destination $env:USERPROFILE\Desktop\jdk-8u261-windows-x64.exe -TransferType Download -Priority High -DisplayName jdk-8u261-windows-x64.exe"

if exist "%USERPROFILE%\desktop\jdk-8u261-windows-x64.exe" goto run
:run

call "%USERPROFILE%\desktop\jdk-8u261-windows-x64.exe"
pause

Example 2: how to download files using cmd

curl http://example.org/picture.jpg

Tags:

Php Example