Win32_PingStatus jscript sample code
The foundations for Manageability in Windows is Windows Management Instrumentation (WMI; formerly WBEM) and WMI extensions for Windows Driver Model (WDM).
ActiveXperts Network Monitor provides the ability to build monitor check routines based on WMI. ActiveXperts has collected more than a hundred WMI samples. You can use these samples as a base for new check routines you can write yourself. The Win32_PingStatus WMI class can be used in ActiveXperts Network Monitor to monitor your servers.
Sample Code
var wbemFlagReturnImmediately = 0x10; var wbemFlagForwardOnly = 0x20; var arrComputers = new Array("\localhost"); for (i = 0; i < arrComputers.length; i++) { WScript.Echo(); WScript.Echo("=========================================="); WScript.Echo("Computer: " + arrComputers[i]); WScript.Echo("=========================================="); var objWMIService = GetObject("winmgmts:\\\\" + arrComputers[i] + "\\root\\CIMV2"); var colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PingStatus", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly); var enumItems = new Enumerator(colItems); for (; !enumItems.atEnd(); enumItems.moveNext()) { var objItem = enumItems.item(); WScript.Echo("Address: " + objItem.Address); WScript.Echo("BufferSize: " + objItem.BufferSize); WScript.Echo("NoFragmentation: " + objItem.NoFragmentation); WScript.Echo("PrimaryAddressResolutionStatus: " + objItem.PrimaryAddressResolutionStatus); WScript.Echo("ProtocolAddress: " + objItem.ProtocolAddress); WScript.Echo("ProtocolAddressResolved: " + objItem.ProtocolAddressResolved); WScript.Echo("RecordRoute: " + objItem.RecordRoute); WScript.Echo("ReplyInconsistency: " + objItem.ReplyInconsistency); WScript.Echo("ReplySize: " + objItem.ReplySize); WScript.Echo("ResolveAddressNames: " + objItem.ResolveAddressNames); WScript.Echo("ResponseTime: " + objItem.ResponseTime); WScript.Echo("ResponseTimeToLive: " + objItem.ResponseTimeToLive); try { WScript.Echo("RouteRecord: " + (objItem.RouteRecord.toArray()).join(",")); } catch(e) { WScript.Echo("RouteRecord: null"); } try { WScript.Echo("RouteRecordResolved: " + (objItem.RouteRecordResolved.toArray()).join(",")); } catch(e) { WScript.Echo("RouteRecordResolved: null"); } WScript.Echo("SourceRoute: " + objItem.SourceRoute); WScript.Echo("SourceRouteType: " + objItem.SourceRouteType); WScript.Echo("StatusCode: " + objItem.StatusCode); WScript.Echo("Timeout: " + objItem.Timeout); try { WScript.Echo("TimeStampRecord: " + (objItem.TimeStampRecord.toArray()).join(",")); } catch(e) { WScript.Echo("TimeStampRecord: null"); } try { WScript.Echo("TimeStampRecordAddress: " + (objItem.TimeStampRecordAddress.toArray()).join(",")); } catch(e) { WScript.Echo("TimeStampRecordAddress: null"); } try { WScript.Echo("TimeStampRecordAddressResolved: " + (objItem.TimeStampRecordAddressResolved.toArray()).join(",")); } catch(e) { WScript.Echo("TimeStampRecordAddressResolved: null"); } WScript.Echo("TimestampRoute: " + objItem.TimestampRoute); WScript.Echo("TimeToLive: " + objItem.TimeToLive); WScript.Echo("TypeofService: " + objItem.TypeofService); } }