다음을 통해 공유


Win32_PingStatus class

The Win32_PingStatus WMI class represents the values returned by the standard ping command. More information about ping can be found in ccccccccccRFC 791.

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

[dynamic, provider("WMIPingProvider"), AMENDMENT]
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.

Success (0)

Other

1 4294967295

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).

None (0)

Loose Source Routing (1)

Strict Source Routing (2)

StatusCode

Data type: uint32

Access type: Read-only

Ping command status codes.

Success (0)

Buffer Too Small (11001)

Destination Net Unreachable (11002)

Destination Host Unreachable (11003)

Destination Protocol Unreachable (11004)

Destination Port Unreachable (11005)

No Resources (11006)

Bad Option (11007)

Hardware Error (11008)

Packet Too Big (11009)

Request Timed Out (11010)

Bad Request (11011)

Bad Route (11012)

TimeToLive Expired Transit (11013)

TimeToLive Expired Reassembly (11014)

Parameter Problem (11015)

Source Quench (11016)

Option Too Big (11017)

Bad Destination (11018)

Negotiating IPSEC (11032)

General Failure (11050)

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).

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

The Get computers ping status, IP, OS version, sp version, uptime and last boot gui PowerShell sample on TechNet Gallery retrieves a variety of information from a specified system, including the Ping status, and displays the information in a GUI.

The Collect userprofile, recycle bin and selective folder size for remote servers PowerShell sample on TechNet Gallery uses Win32_PingStatus to check whether a server is reachable.

The following PowerShell code sample demonstrates the use of Win32_PingStatus.

[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"
}
}
#

The following VBS code sample describes using Win32_PingStatus to retrieve information about a remote web server.

strAddress = InputBox ("Specify an address to ping", WScript.ScriptFullName, "google.com")

If GetOsVersion < "5.01" Then
  MsgBox "Unsupported Operating System", _
         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

Requirements

Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Namespace
Root\CIMV2
MOF
Wmipicmp.mof
DLL
Wmipicmp.dll

See also

Operating System Classes

WMI Tasks: Networking