0

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...

Rafael
  • 111
  • 3
  • 2
    What has your research [shown](http://superuser.com/questions/59465/is-it-possible-to-download-using-the-windows-command-line?rq=1)? – 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
  • you can run vbscript from command with cscript.exe which comes with windows. It has been a while but I think maybe vbscript involving gui runs with wscript.. and vbscript command line uses cscript. something like `cscript //nologo blah.vbs` – barlop Feb 25 '15 at 16:57
  • I hate the syntax of VBScript, i've never got used to it. – Rafael Feb 25 '15 at 16:59
  • @Rafael there is jscript that is native too. Also ultimately once you have the script you don't have to worry about the syntax of the vbscript or jscript language. the windows scripting host supports javascript and vbscript. I haven't tried javascript much and was years ago but it's supported. – barlop Feb 25 '15 at 17:19
  • Uhmm, jscript is better. But I just know Jquery. I needed jscript for a web project and I didn't knew it, so I took the fast way. Just learned the basics of jscript and got to Jquery. Can I use Jquery with windows?? xD – Rafael Feb 25 '15 at 17:25
  • You can use wget (http://gnuwin32.sourceforge.net/packages/wget.htm) and just run it from a network share in your batch file. – Keith Feb 25 '15 at 17:28
  • @KeithLammers Can you make a more complete answer on how I can accomplish it? I didn't get what you meant by network share. Please, add an answer – Rafael Feb 25 '15 at 17:34
  • Sure thing, I'll post some more specific steps as an answer below. – Keith Feb 25 '15 at 19:00

3 Answers3

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]
Keith
  • 309
  • 1
  • 4
  • 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: http://ss64.com/nt/net_use.html – Keith 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.

TOOGAM
  • 15,243
  • 4
  • 41
  • 58
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.

kreemoweet
  • 4,565
  • 17
  • 19