0

This question already has an answer here:

I would like to know if there is a way to make a http download via batch script just with the standards programs in windows (XP and 7) and without PowerShell.

Please, don't give programs I need to install (unless I can install them via command line and without PowerShell).

Can someone please help me?

Edit:
I wanted to know if there is a way with batch script alone, without other types of scripts, I did not see that question but someone marked me as a duplicate...

marked as duplicate by Ramhound, DavidPostill, nc4pk, Moses, Kevin Panko Feb 27 '15 at 21:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    What has your research shown? – Ramhound Feb 25 '15 at 16:39
  • I'm just getting PowerShell scripts and programs i need to manually download and install. I need to make a batch to install programs on fresh installs of Windows, to save me time. – Rafael Feb 25 '15 at 16:42
  • Why can't you use Powershell. Your other options have been depreciated in favor of Powershell which IS a command prompt. – Ramhound Feb 25 '15 at 16:46
  • 1
    Because PowerShell is not a XP standard. And we still deploy some XP because of old hardware. – Rafael Feb 25 '15 at 16:48
  • 1
    Use VBScript then. It also might be smart to write two versions of the script. One for your XP machines and the other for Windows 7. You can safely use the depreciated command if your on Windows XP. – Ramhound Feb 25 '15 at 16:52
2

If you have access to network shares, you can use wget to download files from the command-line.

  1. Download the binaries and dependencies zip files from http://gnuwin32.sourceforge.net/packages/wget.htm.
  2. Extract them to a folder on a network share that your batch file will have access to.
  3. In your batch file, to download a file, put the following line:

    \\servername\sharename\wget.exe [URL]
    

The file will then be downloaded to the working directory, and you can then run your downloaded file in the batch script.

If you don't have access to network shares on the machines that these batch scripts are running on, just copy the wget files into the same folder as the batch script, and call it using:

wget.exe [URL]
  • Oh, just one more question, how do i login into the domain throught command line? My network shares are in the domain – Rafael Feb 25 '15 at 20:58
  • You can use the "net use" command to connect to a share with a user/pass. Check the "Join a password protected file share (Drive MAP)" section on this page for an example: ss64.com/nt/net_use.html – Keith Lammers Feb 26 '15 at 14:28
1

Of course, there is Internet Explorer, which does fit your description because it can be started from the command line, though that is interactive and probably not what you seek.

There may be objects, like WinHttp.WinHttpRequest.5.1 or XMLHTTP, that come with Windows and which can be used to grab a file via HTTP.

It can be used via WSH (Windows Scripting Host).

The number of lines you would need to type are numerous/complex enough that you'll probably just want to make a script and download it (which could be done using the built-in FTP command).

Although, if you're going to download your script, then is there really much advantage gained by downloading that script, rather than downloading a universal tool like cURL or wget?

(In my case, the answer was: yes. But your case might be different, so do think about that answer.)

Out of what comes with the operating system, that (WSH) has been the best solution that I've personally used so far, to accomplish HTTP through automation.

0

Bitsadmin.exe is a command-line tool that comes with Windows. It is a rather complex command, with a very large set of parameters/flags/options. The service it controls (Background Intelligent Transfer Service) is used by Windows itself to download update packages and such, but can be used to perform a simple file download from an arbitrary website.

Not the answer you're looking for? Browse other questions tagged or ask your own question.