' Constants for type of event log entry const EVENTLOG_SUCCESS = 0 const EVENTLOG_ERROR = 1 const EVENTLOG_WARNING = 2 const EVENTLOG_INFORMATION = 4 const EVENTLOG_AUDIT_SUCCESS = 8 const EVENTLOG_AUDIT_FAILURE = 16 ' ' Getting the start time ' StartTime = DateDiff("s","01/01/1970 00:00:00",Now()) Dim objFSO, WshShell Set objFSO = CreateObject("Scripting.FileSystemObject") If (objFSO.FileExists("C:\temp\20MB.zip")) then objFSO.DeleteFile("C:\temp\20MB.zip") Else End If ' ' Test file from http://www.thinkbroadband.com/download.html ' thanks to Thinkbroadband.com ImageFile = "20MB.zip" DestFolder = "C:\temp\" URL = "http://download.thinkbroadband.com/20MB.zip" On Error Resume Next Err.Clear Set xml = CreateObject("Microsoft.XMLHTTP") xml.Open "GET", URL, False xml.Send if xml.Status<>200 Then Err.Raise 8 Err.Description = "Problem with url" Err.Source = "WSH" end if if Err.Number<>0 Then strMessage = Err.Description set objShell = CreateObject("WScript.Shell") objShell.LogEvent EVENTLOG_ERROR, strMessage WScript.Quit Err.Number End If On Error Goto 0 set oStream = createobject("Adodb.Stream") Const adTypeBinary = 1 Const adSaveCreateOverWrite = 2 Const adSaveCreateNotExist = 1 oStream.type = adTypeBinary oStream.open oStream.write xml.responseBody ' Use this form to overwrite a file if it already exists oStream.savetofile DestFolder & ImageFile, adSaveCreateOverWrite oStream.close set oStream = nothing Set xml = Nothing ' ' Getting the end time ' EndTime = DateDiff("s","01/01/1970 00:00:00",Now()) strTimer = EndTime - StartTime strTimer = strTimer + 1 ' Sending back performance data to Operations Manager ' Dim oAPI, oBag Set oAPI = CreateObject("MOM.ScriptAPI") Set oBag = oAPI.CreatePropertyBag() Call oBag.AddValue("Contoso_PerfValue",strTimer) Call oAPI.Return(oBag) ' ' Generate a local event if it takes to ' long time to download the file. Default 5 seconds. If strTimer > 5 Then strMessage = "Download check. It takes to long time to download the file " & URL & ". It took " & strTimer & " seconds." set objShell = CreateObject("WScript.Shell") objShell.LogEvent EVENTLOG_WARNING, strMessage Else End If