2

because Bitsadmin is getting deprecated I would like to hear if you know about an alternative to Download files from within a batch script. Best would be an alternative that already comes with windows so I don't need to download extra stuff.

d0min0r4bb1t
  • 123
  • 1
  • 5

4 Answers4

5

Bacon Bits and I had the same idea at the same time. Here's an example using PowerShell's BitsTransfer module. Save this as a .bat file and run it.

@echo off
setlocal

set "URL=http://cdn.sstatic.net/stackoverflow/img/sprites.svg"
set "SaveAs=sprites.svg"
powershell "Import-Module BitsTransfer; Start-BitsTransfer '%URL%' '%SaveAs%'"
rojo
  • 22,626
  • 5
  • 47
  • 93
  • I would suggest that it's better to just use PowerShell directly so that you don't need to write and save a batch file. – Bill_Stewart May 15 '15 at 15:28
  • 1
    Syntax for executing a powershell script: `powershell -executionpolicy remotesigned ".\basename.ps1"`. Syntax for executing a batch script: `basename`. Gui method for launching a powershell script: Right Click --> Run with Powershell. Gui method for launching a bat script: Double click. Writing and saving a batch file often results in a nicer user experience, Bill. – rojo May 15 '15 at 15:53
  • I recommend running PowerShell commands directly from a PowerShell command window rather than double-clicking from a GUI window. – Bill_Stewart May 15 '15 at 16:02
3

Good news -- BitsAdmin isn't being deprecated.

(I work for the BITS team at Microsoft)

PESMITH_MSFT
  • 332
  • 1
  • 8
  • 1
    why is it so slow compared to wget? – Stepan Yakovenko Apr 30 '20 at 07:53
  • Other questions that are more relevant: why does wget download over my cell connection? I was roaming and the bill was much more than I expected! Or, "when I run wget, suddenly all my other apps run more slowly! How come?" Or, "I was downloading with wget, and rebooted. Why did the download stop?" BITS is designed to be a background downloader: it knows about power states, the cost (at least roughly) of your connection, and more. And it can handle reboots, restarting the downloads. Wget is designed to handle a surprising number of network protocols in the foreground. – PESMITH_MSFT May 05 '20 at 01:03
2

The best alternative to BITSAdmin.exe is to use PowerShell.

If you cannot use PowerShell, you're pretty much stuck with copy, xcopy.exe, and robocopy.exe.

Bacon Bits
  • 26,878
  • 5
  • 51
  • 60
1

How can I download a file with batch file without using any external tools? - you can check this

Probably the powershell is the best alternative Though you still can find vista and XP machines without powershell - if portability is important for you go to WSH.

.I don't think MSXML2.XMLHTTP and WinHTTPRequest (here I've a little bit more powerful tool based on winhttprequest - and more tested ) are going to be deprecated any time soon but they will require WSH or jscript or vbscript or powershell.

jscript.net and webclient will work better for bigger files.

Community
  • 1
  • 1
npocmaka
  • 51,748
  • 17
  • 123
  • 166