PDA

View Full Version : ping کردن یک remote machine با کمک WMI (سورس)



بابک زواری
پنج شنبه 04 اسفند 1384, 18:15 عصر
Dim sHost 'name of Windows XP computer from which
'the PING command will be initiated
Dim sTarget 'name or IP address of remote computer
'to which connectivity will be tested
Dim cPingResults 'collection of instances of Win32_PingStatus class
Dim oPingResult 'single instance of Win32_PingStatus class
sHost = Environment.MachineName
sTarget = "192.168.12.14"
Set cPingResults = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _
sHost & "/root/cimv2"). ExecQuery("SELECT * FROM Win32_PingStatus " & _
"WHERE Address = '" + sTarget + "'")
For Each oPingResult In cPingResults
If oPingResult.StatusCode = 0 Then
If LCase(sTarget) = oPingResult.ProtocolAddress Then
WScript.Echo sTarget & " is responding"
Else
WScript.Echo sTarget & "(" & oPingResult.ProtocolAddress & ") is responding"
End If
Wscript.Echo "Bytes = " & vbTab & oPingResult.BufferSize
Wscript.Echo "Time (ms) = " & vbTab & oPingResult.ResponseTime
Wscript.Echo "TTL (s) = " & vbTab & oPingResult.ResponseTimeToLive
Else
WScript.Echo sTarget & " is not responding"
WScript.Echo "Status code is " & oPingResult.StatusCode
End If
Next

HO457
پنج شنبه 04 اسفند 1384, 18:58 عصر
ممنون آقای زواری. بازم مثل همیشه مارو شرمنده کردید. :قلب:

mamadwins
چهارشنبه 30 آبان 1386, 10:04 صبح
چطور می توان با ping چک کرد که سرور صل است یا نه؟