DownloadUrl = "http://ovh.net/files/10Mb.dat"
FileLocation = "Download.dat"
Wscript.Echo "Start Downloading"
Set ObjXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
ObjXMLHTTP.open "GET", DownloadUrl, false, "username", "password"
'http.setTimeouts 5000, 5000, 10000, 10000 'ms - resolve, connect, send, receive'
'http.setRequestHeader "Authorization", "Basic MY_AUTH_STRING"
ObjXMLHTTP.send()
If ObjXMLHTTP.Status = 200 Then
Set ObjADOStream = CreateObject("ADODB.Stream")
ObjADOStream.Open
ObjADOStream.Type = 1
'adTypeBinary
ObjADOStream.Write ObjXMLHTTP.ResponseBody
ObjADOStream.Position = 0
'Set the stream position to the start
Set ObjFSO = Createobject("Scripting.FileSystemObject")
If ObjFSO.Fileexists(FileLocation) Then ObjFSO.DeleteFile FileLocation
Set ObjFSO = Nothing
ObjADOStream.SaveToFile FileLocation
ObjADOStream.Close
Set ObjADOStream = Nothing
Wscript.Echo "Download Completed: " + FileLocation
Else
Wscript.Echo "File Not Found"
End if
Set ObjXMLHTTP = Nothing
No comments:
Post a Comment