Here is a how-to.
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET", 'http://www.nikem.de/Willkommen_files/chart1.jpg', false);
xmlhttp.send(null);
var adTypeBinary = 1
var adSaveCreateOverWrite = 2
var BinaryStream = new ActiveXObject("ADODB.Stream");
//Specify stream type - we want To save binary data.
BinaryStream.Type = adTypeBinary
//Open the stream And write binary data To the object
BinaryStream.Open();
BinaryStream.Write(xmlhttp.responseBody);
//Save binary data To disk
BinaryStream.SaveToFile ("C:\chart1.jpg", adSaveCreateOverWrite);
WScript.Echo("Ready");
I used the binary format in the sample. So that data are saved as they come.
A text-based version can also be usefull.
It is also possible to support defirent encodings e.g. UTF-8.
Detailed Informations can be found under:
http://msdn.microsoft.com/en-us/library/ms535874(v=vs.85).aspx
Keine Kommentare:
Kommentar veröffentlichen