download file using command prompt windows code example

Example: 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

Tags:

Php Example