HTTPdownload.vbs (I added the first IF statement - maybe it should be improved (I have no experience with .vbs)) .@cscript /NOLOGO /E:VBS HTTPdownload.vbs "http://www.kockarna.si/slike.zip" "."
FIle in the .cmd (slike.zip) is located on my website - it is safe to download. It contains some .jpg files of a flat. (size 36 Mbytes).if WScript.Arguments.Count <> 2 then
WScript.Echo "Missing parameters"
HTTPDownload WScript.Arguments(0), WScript.Arguments(1)
Sub HTTPDownload( myURL, myPath )
' This Sub downloads the FILE specified in myURL to the path specified in myPath.
' myURL must always end with a file name
' myPath may be a directory or a file name; in either case the directory must exist
' Written by Rob van der Woude
' Based on a script found on the Thai Visa forum
' Standard housekeeping
Dim i, objFile, objFSO, objHTTP, strFile, strMsg
Const ForReading = 1, ForWriting = 2, ForAppending = 8
' Create a File System Object
Set objFSO = CreateObject( "Scripting.FileSystemObject" )
' Check if the specified target file or folder exists,
' and build the fully qualified path of the target file
If objFSO.FolderExists( myPath ) Then
strFile = objFSO.BuildPath( myPath, Mid( myURL, InStrRev( myURL, "/" ) + 1 ) )
ElseIf objFSO.FolderExists( Left( myPath, InStrRev( myPath, "\" ) - 1 ) ) Then
strFile = myPath
WScript.Echo "ERROR: Target folder not found."
' Create or open the target file
Set objFile = objFSO.OpenTextFile( strFile, ForWriting, True )
' Create an HTTP object
Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
' Download the specified URL
objHTTP.Open "GET", myURL, False
' Write the downloaded byte stream to the target file
For i = 1 To LenB( objHTTP.ResponseBody )
objFile.Write Chr( AscB( MidB( objHTTP.ResponseBody, i, 1 ) ) )
' Close the target file
The problem I have is: this .vbs download is veeeeeeeeeery slow. If I use wget.exe it downloads with the expected speed.
What I noticed with this .vbs: output file is created with the size of zero bytes (of course) - size does not change for a while (actual download of the file occurs). Then size starts to increment very slowly and CPU usage is 100% (cscript.exe) - this means that the last FOR-NEXT loop is the problem.
Any ideas/alternatives? Do you have the same problem?
I would like to use this (or similar) download .vbs script in my .cmd (I don't want to use wget.exe).