Ветеран
Сообщения: 27449
Благодарности: 8088
|
Профиль
|
Отправить PM
| Цитировать
Цитата megaloman:
Похоже, во всём виноват Windows. Проверил на Win XP, 2003 -работает. Win 2000 (у меня сервер) - увы. Там пинг по любому выдаёт ErrorLevel=0. Ни мой макрос, никакой батник с ping-ом и дальнейшей проверкой на ErrorLevel там работать не будут. »
|
К сожалению, помнится, было именно так. Если не пугают сторонние компоненты (в WMI в 2000 класс «Win32_PingStatus» тоже, к сожалению, отсутствует) — попробуйте метод «.Ping()» объекта «IPNetwork» из комплекта «System Scripting Runtime 1.5»:
читать дальше »
Цитата:
Ping Method (IPNetwork Object)
The Ping method sends an ICMP echo request to the specified host and returns information about the response, if one is received.
Long =
oIPNetwork.Ping(
Destination,
ResponseTime,
SourceOfResponse,
Timeout,
TTL,
BufferSize
)
Parameters
Destination as String
String containing the name or the IP-address of the host to ping.
(optional) ResponseTime as Variant
A Variant variable of sub-type Long which returns the number of milliseconds passed between sending the echo request and receiving the response. The variable will only hold a value if the method returns sscPingSuccess (=0), sscPingDestinationUnreachable (=10) or sscPingTimeExceeded (=20).
(optional) SourceOfResponse as Variant
A Variant variable of sub-type String which returns the IP-address from which the received response was sent. The variable will only hold a value if the method returns sscPingSuccess (=0), sscPingDestinationUnreachable (=10) or sscPingTimeExceeded (=20).
(optional) Timeout as Long
Number of milliseconds the method will wait for a response before it returns with sscPingTimeout (=30). If this parameter is not specified, a timeout value of 1000 milliseconds will be used.
(optional) TTL as Long
Time-to-Live (1-255) value of the echo request packet. If this parameter is not specified, the system default value (NT 4.0: 128) will be used.
(optional) BufferSize as Long
Size in bytes (1 - 64000) of dummy data to be contained in the echo request packet. If this parameter is not specified, a buffer size of 32 will be used.
Return Value
The method returns one of the following result codes:
Result Code Description
sscPingSuccess = 0 A valid ICMP Echo Response packet has been received.
sscPingDestinationUnreachable = 10 An ICMP Destination Unreachable packet has been received.
sscPingTimeExceeded = 20 An ICMP Time Exceeded packet has been received, which may be caused by a TTL value being too small.
sscPingTimeout = 30 No response has been received within the timeout period.
sscPingInvalidParameter = 100 On or more of the provided parameters contain an invalid value.
sscPingSocketError = 110 An WinSocket related error occurred.
sscPingInvalidHostAddress = 120 The specified host address (hostname or IP-address) is invalid.
Remarks
The response time is accurate to 10 milliseconds. This means that if the response time returned is 0, as many as 9 milliseconds may have passed.
The ping method uses the raw sockets feature of WinSock 2.x. On Windows NT 4.0 SP4+ and Windows 2000, the use of raw sockets is limited to administrators. This default behavior can be changed in case of Windows NT 4.0 but not in case of Windows 2000. More information can be found in KB-Article Q195445.
|
|
Отправлено: 04:19, 16-10-2010
| #17
|