Win32_PingStatus class
Applies to: desktop apps only
The Win32_PingStatus WMI class represents the values returned by the standard ping command. More information about ping can be found in RFC 791.
Starting with Windows Vista, Win32_PingStatus can return data for computers that have both IPv4 addresses and IPv6 addresses.
Windows Server 2003 and Windows XP: Win32_PingStatus only returns data for computers running IPv4. For more information, see IPv6 and IPv4 Support in WMI.
The following syntax is simplified from Managed Object Format (MOF) code and includes all of the inherited properties. Properties are listed in alphabetic order, not MOF order.
Syntax
class Win32_PingStatus
{
string Address;
uint32 BufferSize = 32;
boolean NoFragmentation = FALSE;
uint32 PrimaryAddressResolutionStatus;
string ProtocolAddress = "";
string ProtocolAddressResolved = "";
uint32 RecordRoute = 0;
boolean ReplyInconsistency;
uint32 ReplySize;
boolean ResolveAddressNames = FALSE;
uint32 ResponseTime;
uint32 ResponseTimeToLive;
string RouteRecord[];
string RouteRecordResolved[];
String SourceRoute = "";
uint32 SourceRouteType = 0;
uint32 StatusCode;
uint32 Timeout = 1000;
uint32 TimeStampRecord[];
string TimeStampRecordAddress[];
string TimeStampRecordAddressResolved[];
uint32 TimeStampRoute = 0;
uint32 TimeToLive = 80;
uint32 TypeofService = 0;
};
Members
The Win32_PingStatus class has these types of members:
Properties
The Win32_PingStatus class has these properties.
- Address
-
- Data type: string
- Access type: Read-only
- Qualifiers: Key
Value of the address requested. The form of the value can be either the computer name ("wxyz1234"), IPv4 address ("192.168.177.124"), or IPv6 address ("2010:836B:4179::836B:4179").
- BufferSize
-
- Data type: uint32
- Access type: Read-only
- Qualifiers: Key
Buffer size sent with the ping command. The default value is 32.
- NoFragmentation
-
- Data type: boolean
- Access type: Read-only
- Qualifiers: Key
If TRUE, "Do not Fragment" is marked on the packets sent. The default is FALSE, not fragmented.
- PrimaryAddressResolutionStatus
-
- Data type: uint32
- Access type: Read-only
Status of the address resolution process. If successful, the value is 0 (zero). Any other value indicates an unsuccessful address resolution.
- ProtocolAddress
-
- Data type: string
- Access type: Read-only
- Qualifiers: MaxLen (4096)
Address that the destination used to reply. The default is "".
- ProtocolAddressResolved
-
- Data type: string
- Access type: Read-only
- Qualifiers: MaxLen (4096)
Resolved address corresponding to the ProtocolAddress property. The default is "".
- RecordRoute
-
- Data type: uint32
- Access type: Read-only
- Qualifiers: Key
How many hops should be recorded while the packet is in route. The default is 0 (zero).
- ReplyInconsistency
-
- Data type: boolean
- Access type: Read-only
Inconsistent reply data is reported.
- ReplySize
-
- Data type: uint32
- Access type: Read-only
Represents the size of the buffer returned.
- ResolveAddressNames
-
- Data type: boolean
- Access type: Read-only
- Qualifiers: Key
Command resolves address names of output address values. The default is FALSE, which indicates no resolution.
- ResponseTime
-
- Data type: uint32
- Access type: Read-only
Time elapsed to handle the request.
- ResponseTimeToLive
-
- Data type: uint32
- Access type: Read-only
Time to live from the moment the request is received.
- RouteRecord
-
- Data type: string array
- Access type: Read-only
Record of intermediate hops.
- RouteRecordResolved
-
- Data type: string array
- Access type: Read-only
Resolved address that corresponds to the RouteRecord value.
- SourceRoute
-
- Data type: String
- Access type: Read-only
- Qualifiers: Key
Comma-separated list of valid Source Routes. The default is "".
- SourceRouteType
-
- Data type: uint32
- Access type: Read-only
- Qualifiers: Key
Type of source route option to be used on the host list specified in the SourceRoute property. If a value outside of the ValueMap is specified, then 0 (zero) is assumed. The default is 0 (zero).
Value Meaning - 0
None
- 1
Loose Source Routing
- 2
Strict Source Routing
- StatusCode
-
- Data type: uint32
- Access type: Read-only
Ping command status codes.
- Timeout
-
- Data type: uint32
- Access type: Read-only
- Qualifiers: Key
Time-out value in milliseconds. If a response is not received in this time, no response is assumed. The default is 1000 milliseconds.
- TimeStampRecord
-
- Data type: uint32 array
- Access type: Read-only
Record of time stamps for intermediate hops.
- TimeStampRecordAddress
-
- Data type: string array
- Access type: Read-only
Intermediate hop that corresponds to the TimeStampRecord value.
- TimeStampRecordAddressResolved
-
- Data type: string array
- Access type: Read-only
Resolved address that corresponds to the TimeStampRecordAddress value.
- TimeStampRoute
-
- Data type: uint32
- Access type: Read-only
- Qualifiers: Key
How many hops should be recorded with time stamp information while the packet is in route. A time stamp is the number of milliseconds that have passed since midnight Universal Time (UT). If the time is not available in milliseconds or cannot be provided with respect to midnight UT, then any time may be inserted as a time stamp, provided the high order bit of the Timestamp property is set to 1 (one) to indicate the use of a nonstandard value. The default is 0 (zero).
- TimeToLive
-
- Data type: uint32
- Access type: Read-only
- Qualifiers: Key
Life span of the ping packet in seconds. The value is treated as an upper limit. All routers must decrement this value by 1 (one). When this value becomes 0 (zero), the packet is dropped by the router. The default value is 80 seconds. The hops between routers rarely take this amount of time.
- TypeofService
-
- Data type: uint32
- Access type: Read-only
- Qualifiers: Key
Type of service that is used. The default value is 0 (zero).
Value Meaning - 0
Normal
- 2
Minimize Monetary Cost
- 4
Maximize Reliability
- 8
Maximize Throughput
- 16
Minimize Delay
Remarks
This class does not support enumeration. For more information about implementing WMI enumeration in C++, see Enumerating WMI. In scripting, Win32_PingStatus does not support the enumeration calls SWbemServices.InstancesOf or SWbemObject.Instances. It does support SWbemServices.ExecQuery and SWbemServices.GetObject.
Examples
For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.
For C++ code examples, see WMI C++ Application Examples.
Requirements
|
Minimum supported client | Windows XP |
|---|---|
|
Minimum supported server | Windows Server 2003 |
|
Namespace |
\root\CIMV2 |
|
MOF |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 3/9/2012
<#
.SYNOPSIS
Demonstrates use of the Win32_PingStatus WMI class
.DESCRIPTION
This script is a community content MSDN sample,using PowerShell
.NOTES
File Name : Get-PingStatus
Author : Thomas Lee - tfl@psp.co.uk
Requires : PowerShell V2 CTP3
.LINK
Sample posted to:
http://pshscripts.blogspot.com/2009/03/get-httpversionps1.html
Original MSDN sample at:
http://msdn.microsoft.com/en-us/library/system.net.httpversion.aspx
.PARAMETER Comp
The computer you want to ping - should be resolvable by DNS
.EXAMPLE
PSH [C:\foo]: .\Get-PingStaus.ps1 blogger.com
Computer to ping: blogger.com
Computer responded in: 127ms
.EXAMPLE
PSH [C:\foo]: "blogger.com", "Localhost" | .\get-pingstatus.PS1'
Computer to ping: blogger.com
Computer responded in: 127ms
Computer to ping: Localhost
Computer responded in: 0ms
.EXAMPLE
PSH [C:\foo]: .\Get-PingStaus.ps1
Computer to ping: localhost
Computer responded in: 0ms
#>
[Cmdletbinding()]
param (
[Parameter(Position=0,mandatory=$false,ValueFromPipeline=$true)]
[string] $comp = "localhost")
###
# Start of Script
###
Process {
# Display intput
"Computer to ping: $comp"
# Now ping the system
$ping = get-wmiobject -Query "select * from win32_pingstatus where Address='$comp'"
# Display Results
if ($ping.statuscode -eq 0) {
"Computer responded in: {0}ms" -f $ping.responsetime
}
else {
"Computer did not respond"
}
}
#
- 3/25/2009
- Thomas Lee
- 10/21/2009
- Thomas Lee
<#
.SYNOPSIS
Demonstrates use of the Win32_PingStatus WMI class
.DESCRIPTION
This script is a community content MSDN sample,using PowerShell
.NOTES
File Name : Get-PingStatus
Author : Thomas Lee - tfl@psp.co.uk
Requires : PowerShell V2 CTP3
.LINK
Sample posted to:
http://pshscripts.blogspot.com
Original MSDN sample at:
http://msdn.microsoft.com/en-us/library/aa394350(VS.85).aspx
.PARAMETER Comp
The computer you want to ping - should be resolvable by DNS
.EXAMPLE
PSH [C:\foo]: .\Get-PingStaus.ps1 blogger.com
Computer to ping: blogger.com
Computer responded in: 127ms
.EXAMPLE
PSH [C:\foo]: "blogger.com", "Localhost" | . 'C:\foo\to post\get-pingstatus.PS1'
Computer to ping: blogger.com
Computer responded in: 127ms
Computer to ping: Localhost
Computer responded in: 0ms
.EXAMPLE
PSH [C:\foo]: .\Get-PingStaus.ps1
Computer to ping: localhost
Computer responded in: 0ms
#>
[Cmdletbinding()]
param (
[Parameter(Position=0,mandatory=$false,ValueFromPipeline=$true)]
[string] $comp = "localhost")
###
# Start of Script
###
Process {
# Display intput
"Computer to ping: $comp"
# Now ping the system
$ping = get-wmiobject -Query "select * from win32_pingstatus where Address='$comp'"
# Display Results
if ($ping.statuscode -eq 0) {
"Computer responded in: {0}ms" -f $ping.responsetime
}
else {
"Computer did not respond"
}
}
- 3/25/2009
- Thomas Lee
- 10/21/2009
- Thomas Lee
strAddress = InputBox ("Specify an address to ping", WScript.ScriptFullName, "google.com")
If GetOsVersion < "5.01" Then
MsgBox "This will only work In Windows XP and later", _
vbOKOnly + vbExclamation, WScript.ScriptFullName
WScript.Quit
End If
Set objPing = GetObject("winmgmts:").Get("Win32_PingStatus.Address='" & strAddress & "'")
With objPing
Wscript.Echo "Address : " & .Address
Wscript.Echo "Buffer size : " & .BufferSize
Wscript.Echo "No Fragmentation : " & .NoFragmentation
Wscript.Echo "PrimaryAddressResolutionStatus : " & .PrimaryAddressResolutionStatus
Wscript.Echo "ProtocolAddress : " & .ProtocolAddress
Wscript.Echo "ProtocolAddressResolved : " & .ProtocolAddressResolved
Wscript.Echo "RecordRoute : " & .RecordRoute
Wscript.Echo "ReplyInconsistency : " & .ReplyInconsistency
Wscript.Echo "ReplySize : " & .ReplySize
Wscript.Echo "ResolveAddressNames : " & .ResolveAddressNames
Wscript.Echo "ResponseTime : " & .ResponseTime
Wscript.Echo "ResponseTimeToLive : " & .ResponseTimeToLive
If IsNull (.RouteRecord) Then
Wscript.Echo "RouteRecord : Null"
Else
Wscript.Echo "RouteRecord : " & _
Join (.RouteRecord, "; ")
End If
If IsNull (.RouteRecordResolved) Then
Wscript.Echo "RouteRecordResolved : Null"
Else
Wscript.Echo "RouteRecordResolved : " & _
Join (.RouteRecordResolved, "; ")
End If
Wscript.Echo "SourceRoute : " & .SourceRoute
Wscript.Echo "SourceRouteType : " & GetSourceRouteType(.SourceRouteType)
Wscript.Echo "Status code : " & GetStatusCode(.StatusCode)
Wscript.Echo "Timeout : " & .TimeOut
If IsNull (.TimeStampRecord) Then
Wscript.Echo "TimeStampRecord : Null"
Else
Wscript.Echo "TimeStampRecord : " & _
Join (.TimeStampRecord, "; ")
End If
If IsNull (.TimeStampRecordAddress) Then
Wscript.Echo "TimeStampRecordAddress : Null"
Else
Wscript.Echo "TimeStampRecordAddress : " & _
Join (.TimeStampRecordAddress, "; ")
End If
If IsNull (.TimeStampRecordAddressResolved) Then
Wscript.Echo "TimeStampRecordAddressResolved : Null"
Else
Wscript.Echo "TimeStampRecordAddressResolved : " & _
Join (.TimeStampRecordAddressResolved, "; ")
End If
Wscript.Echo "TimeStampRoute : " & .TimeStampRoute
Wscript.Echo "TimeToLive : " & .TimeToLive
Wscript.Echo "TypeOfService : " & GetTypeOfService(.TypeOfService)
End With
MsgBox "The END"
' ___________________
Function GetOsVersion
Set objWMIService = GetObject("winmgmts:")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_OperatingSystem",,48)
For Each objItem In colItems
WScript.Echo objItem.Version
GetOsVersion = objItem.Version
Next
Set colItems = Nothing : Set objWMIService = Nothing
End Function
' ____________________________________________
Function GetSourceRouteType (intSourceRouteType)
Dim strType
Select Case intSourceRouteType
case 1
strType = "Loose Source Routing"
case 2
strType = "Strict Source Routing"
case Else
' Default - 0 - or any other value.
strType = intSourceRouteType & " - None"
End Select
GetSourceRouteType = strType
End Function
' ______________________________________
Function GetTypeOfService (intServiceType)
Dim strType
Select Case intServiceType
case 2
strType = "Minimize Monetary Cost"
case 4
strType = "Maximize Reliability"
case 8
strType = "Maximize Throughput"
case 16
strType = "Minimize Delay"
Case Else
' Default - 0 - or any other value.
strType = intServiceType & " - Normal"
End Select
GetTypeOfService = strType
End Function
' ____________________________
Function GetStatusCode (intCode)
Dim strStatus
Select Case intCode
case 0
strStatus = "Success"
case 11001
strStatus = "Buffer Too Small"
case 11002
strStatus = "Destination Net Unreachable"
case 11003
strStatus = "Destination Host Unreachable"
case 11004
strStatus = "Destination Protocol Unreachable"
case 11005
strStatus = "Destination Port Unreachable"
case 11006
strStatus = "No Resources"
case 11007
strStatus = "Bad Option"
case 11008
strStatus = "Hardware Error"
case 11009
strStatus = "Packet Too Big"
case 11010
strStatus = "Request Timed Out"
case 11011
strStatus = "Bad Request"
case 11012
strStatus = "Bad Route"
case 11013
strStatus = "TimeToLive Expired Transit"
case 11014
strStatus = "TimeToLive Expired Reassembly"
case 11015
strStatus = "Parameter Problem"
case 11016
strStatus = "Source Quench"
case 11017
strStatus = "Option Too Big"
case 11018
strStatus = "Bad Destination"
case 11032
strStatus = "Negotiating IPSEC"
case 11050
strStatus = "General Failure"
case Else
strStatus = intCode & " - Unknown"
End Select
GetStatusCode = strStatus
End Function
clear
oWMI = getobject("winmgmts:")
* Specify address or computer name or URL
* cAddress = "192.168.1.125"
cAddress = "apple.com" && Works 21 June 2009 - resolves to 17.112.152.57
* cAddress = "computer_name
if os() < "Windows 5.01"
messagebox("This will only work in Windows XP and later")
return
endif
oPings = oWMI.ExecQuery([Select * from WIN32_Pingstatus where address='] + cAddress + ['])
for each oPing in oPings
* This class does not actually support enumeration,
* there is only one ping object returned and this is how to access it.
? "Status code: ", GetStatusCode(oPing.statuscode)
?
? "Address: ", oPing.Address
? "Buffer size", oPing.BufferSize
? "No Fragmentation", oPing.NoFragmentation
? "PrimaryAddressResolutionStatus", oPing.PrimaryAddressResolutionStatus
? "ProtocolAddress", oPing.ProtocolAddress
? "ProtocolAddressResolved", oPing.ProtocolAddressResolved
? "RecordRoute", oPing.RecordRoute
? "ReplyInconsistency", oPing.ReplyInconsistency
? "ReplySize", oPing.ReplySize
? "ResolveAddressNames", oPing.ResolveAddressNames
? "ResponseTime", oPing.ResponseTime
? "ResponseTimeToLive", oPing.ResponseTimeToLive
? "SourceRoute", oPing.SourceRoute
? "SourceRouteType", GetSourceRouteType(oPing.SourceRouteType)
? "Timeout", oPing.timeout
? "TimestampRoute", oPing.TimestampRoute
? "TimeToLive", oPing.TimeToLive
? "TypeofService", GetTypeOfService(oPing.TypeofService)
if not isnull(oPing.RouteRecord)
for each oItem in oPing.RouteRecord
? oItem
next
endif
if not isnull(oPing.RouteRecordResolved)
for each oItem in oPing.RouteRecordResolved
? oItem
next
endif
if not isnull(oPing.RouteRecordResolved)
for each oItem in oPing.TimeStampRecord
? oItem
next
endif
if not isnull(oPing.TimeStampRecordAddress)
for each oItem in oPing.TimeStampRecordAddress
? oItem
next
endif
if not isnull(oPing.TimeStampRecordAddressResolved)
for each oItem in oPing.TimeStampRecordAddressResolved
? oItem
next
endif
next
procedure GetSourceRouteType
lparameters nSourceRouteType
local cType
do case
case nSourceRouteType = 1
cType = "Loose Source Routing"
case nSourceRouteType = 2
cType = "Strict Source Routing"
otherwise
* Default - 0 - or any other value.
cType = "None"
endcase
return cType
endproc
procedure GetTypeOfService
lparameters nServiceType
local cType as string
do case
case nServiceType = 2
cType = "Minimize Monetary Cost"
case nServiceType = 4
cType = "Maximize Reliability"
case nServiceType = 8
cType = "Maximize Throughput"
case nServiceType = 16
cType = "Minimize Delay"
otherwise
* Default - 0 - or any other value.
cType = "Normal"
endcase
return cType
endproc
procedure GetStatusCode (cCode as string) as string
local cStatus
do case
case cCode = 0
cStatus = "Success"
case cCode = 11001
cStatus = "Buffer Too Small"
case cCode = 11002
cStatus = "Destination Net Unreachable"
case cCode = 11003
cStatus = "Destination Host Unreachable"
case cCode = 11004
cStatus = "Destination Protocol Unreachable"
case cCode = 11005
cStatus = "Destination Port Unreachable"
case cCode = 11006
cStatus = "No Resources"
case cCode = 11007
cStatus = "Bad Option"
case cCode = 11008
cStatus = "Hardware Error"
case cCode = 11009
cStatus = "Packet Too Big"
case cCode = 11010
cStatus = "Request Timed Out"
case cCode = 11011
cStatus = "Bad Request"
case cCode = 11012
cStatus = "Bad Route"
case cCode = 11013
cStatus = "TimeToLive Expired Transit"
case cCode = 11014
cStatus = "TimeToLive Expired Reassembly"
case cCode = 11015
cStatus = "Parameter Problem"
case cCode = 11016
cStatus = "Source Quench"
case cCode = 11017
cStatus = "Option Too Big"
case cCode = 11018
cStatus = "Bad Destination"
case cCode = 11032
cStatus = "Negotiating IPSEC"
case cCode = 11050
cStatus = "General Failure"
otherwise
cStatus = "Unknown"
endcase
return cStatus
endproc
- 6/21/2009
- StuartDunkeld
- 6/21/2009
- StuartDunkeld