Microsoft Operations Manager

Alternatives to the INet Object

For new scripts, use the following methods and properties of the MSXMLobject to achieve equivalent results.

Deprecated members Equivalents
INet.GetFTPFile Openmethod, Sendmethod, and the responseTextproperty of the MSXMLobject
INet.GetHTTPFile Openmethod, Sendmethod, and the responseTextproperty of the MSXMLobject
INet.Ping Openmethod and Sendmethod of the MSXMLobject

Examples

The following example uses the MSXMLobject to request a document from an FTP server.

[VBScript] 
'*********************************************************************
' Routine: Function GetFTPFile
' Purpose: A replacement for the INet.GetFTPFile method
'**********************************************************************
Function GetFTPFile(strURL)
	Dim objXML
	Dim strFTPResponse

	Set objXML = CreateObject("Msxml2.XMLHTTP")

	Call objXML.Open("GET", strURL, False)
	Call objXML.Send()

	strFTPResponse = objXML.responseText

	Set objXML = Nothing

	GetFTPFile = strFTPResponse
End Function

The following example uses the MSXMLobject to request a document from an HTTP server.

[VBScript] 
'*********************************************************************
' Routine: Function GetHTTPFile
' Purpose: A replacement for the INet.GetHTTPFile method
'**********************************************************************
Function GetHTTPFile(strURL)
	Dim objXML
	Dim strHTTPResponse

	Set objXML = CreateObject("Msxml2.XMLHTTP")

	Call objXML.Open("GET", strURL, False)
	Call objXML.Send()

	strHTTPResponse = objXML.responseText

	Set objXML = Nothing

	GetHTTPFile = strHTTPResponse
End Function

The following example checks the availability and performance of an HTTP server using a test request sent by the MSXMLobject. The example assumes that there is a MOM processing rule configured to monitor the event created by this script.

[JScript] 
// Constants
EVENT_TYPE_ERROR = 1;
EVENT_SOURCE = "HTTP Ping - availability";

var objParams = ScriptContext.Parameters;
var strURL = objParams.Get("strURL");

var http = new ActiveXObject("MSXML2.XMLHTTP");
http.open ("GET", strURL, false);
var timebefore = new Date();
http.send();
var timeafter = new Date();
var diff = timeafter - timebefore;
if (http.status != "200")
{
	CreateEvent(5001, EVENT_SOURCE, EVENT_TYPE_ERROR, "", "The
server isn't available.");
	// Errors are often returned much faster than a successful
request. All requests with
	// error status codes are assigned a higher ping value of 2000
ms.
	diff = 2000; 
}

CreatePerformanceData("HTTP Ping", "Time Elapsed", strURL, diff,
"");

function CreateEvent(intEventNumber, strEventSource, intEventType,
strSourceComputer, strEventMessage)
{
	var objEvent = ScriptContext.CreateEvent();
	objEvent.EventNumber = intEventNumber;
	objEvent.EventSource = strEventSource;
	objEvent.EventType = intEventType;
	if (strSourceComputer != ""){
		objEvent.SourceComputer = strSourceComputer;
		objEvent.LoggingComputer = strSourceComputer;
}
	objEvent.Message = strEventMessage;
	ScriptContext.Submit(objEvent); 				 
}


function CreatePerformanceData (strObjectName, strCounterName,
strInstanceName, dblSampleValue, strSrcComputer)
{
	var objPerfData = ScriptContext.CreatePerfData();

	if (strSrcComputer != "")
	{
		objPerfData.SourceComputer = strSrcComputer;
}
	objPerfData.ObjectName = strObjectName;
	objPerfData.CounterName = strCounterName;
	objPerfData.InstanceName = strInstanceName;
	objPerfData.Value = dblSampleValue;

	ScriptContext.Submit(objPerfData);
}

For more information about the XMLHTTP object, see the Microsoft XML Core Services SDK.

To save the response text to a file, use the Scripting FileSystemObject object.


Did you find this information useful? Please send your suggestions and comments about the documentation to momsdk@microsoft.com.