How to i get a batch file to download a file from a url [closed]

I've been trying for two days now to try to find something that works. I've been trying to make a batch file download files from a link.

I've tried powershell scripts and invoke-webquest and these crazy four paragraph long download scripts that doesn't work for me.

I would like some help because I'm kind of getting frustrated, but just wondering if anyone has any other suggestions, or if there's a different way to use these scripts..


We're missing a bit of information in this post to construct a proper answer.

In any case, Powershell is going to help a lot here.

Powershell can do it with just one line of code (or more if you want to go fancy here.

Because I don't know the url of the file you want to download, I'll use Chrome as example, and save the file to the download folder in your user profile.

The url for Chrome is: https://www.google.com/intl/en_us/chrome/

The oneliner script would be:

Invoke-WebRequest -uri "https://www.google.com/intl/en_us/chrome" -OutFile "$env:userprofile\Downloads\ChromeSetup.exe"

If you want to make it a bit more fancy, you could write the script as follows:

I'll use Notepad++ in this example.

$DownloadUrl = "https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8/npp.8.0.Installer.exe"

$SaveTo = "C:\temp\notepad++_setup.exe"

Invoke-WebRequest -uri $DownloadUrl -OutFile $SaveTo

Both scripts are basically the same thing, where one uses just one line with no variables, and the second one stores the parameters into variables such that editing the script lateron is easier, especially if this becomes part of a large script, then you can move the variables to the top of your script so you only need to search there in case you ever need to alter it.


Ok so it took me a while but i found this and it worked perfectly fine

@echo off Title Download code from pastebin and display it with batch Set "url=https://pastebin.com/raw/vzx1dEdW" for %%# in (%url%) do ( set "File=%tmp%%%~n#.txt" ) Call :Download "%url%" "%File%" If exist "%File%" ( ( Type "%File%")>con Rem to save the contents in new text file ( Type "%File%" > Multi_Downloading_Files.txt) ) Start "" Multi_Downloading_Files.txt Pause>nul & Exit ::********************************************************************************* :Download Powershell.exe -command "(New-Object System.Net.WebClient).DownloadFile('%1','%2')" exit /b ::*********************************************************************************

i got it from https://stackoverflow.com/questions/48860214/copy-text-from-url-with-a-batch-file