Hi Philippe,
This method can be used with files which reside on a local or a network drive. It cannot download files from the Internet.
You can download a file by using the script below. It sends an HTTP request by using the XMLHTTP ActiveX object (it's also possible to use the WinHttpRequest ActiveX object instead).
[JScript, C#Script, C++Script]
// Specify the source and destination file names
var strHDLocation = "c:\\temp\\filename";
// Download the file
var objHTTP = new ActiveXObject("MSXML2.XMLHTTP");
//or
//var objHTTP = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
objHTTP.open("GET", strFileURL, false);
objHTTP.send();
if (objHTTP.Status == 200)
{
var objADOStream = new ActiveXObject("ADODB.Stream");
objADOStream.Open();
objADOStream.Type = 1; //adTypeBinary
objADOStream.Write(objHTTP.ResponseBody);
objADOStream.Position = 0; //Set the stream position to the start
var objFSO = new ActiveXObject("Scripting.FileSystemObject");
if (objFSO.FileExists(strHDLocation)) objFSO.DeleteFile(strHDLocation)
objADOStream.SaveToFile(strHDLocation);
objADOStream.Close();
}