VBA : Internet: Ping a computer in VBA using WMI 
Options: Save as PDF | Save attached file | Toggle line numbers
Details:
| Type: | function |
| Added By: | Rembo |
| Short Description: | Windows Management Instrumentation (WMI) provides a uniform interface for any local or remote applications or scripts that obtain management data from a computer system, a network, or an enterprise. Information such as a computer name, logged in user and even process data can be easily retrieved using any script language that supports ActiveX objects. |
| Notes: | With the Scripting API for WMI, you can develop quick, simple scripts or complex Microsoft Visual Basic management applications. Scripting gives you the same capability of getting information or of configuring most objects in an enterprise as you would have through a C++ or C# application. Note 1: you cannot write a WMI provider in script or Visual Basic. Note 2: Depending on your version of Windows the WMI classes and objects vary in features and functionality. |
| Added: | Feb 12 2009 at 11:37 AM |
| Modified: | Feb 12 2009 at 11:38 AM |
| Related URLs |
Usage:
Run the routine TestPing to see the result of a ping to scriptorium.serve-it.nl
Code:
Function sPing(sHost) As String Dim oPing As Object, oRetStatus As Object Set oPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _ ("select * from Win32_PingStatus where address = '" & sHost & "'") For Each oRetStatus In oPing If IsNull(oRetStatus.StatusCode) Or oRetStatus.StatusCode <> 0 Then sPing = "Status code is " & oRetStatus.StatusCode Else sPing = "Pinging " & sHost & " with " & oRetStatus.BufferSize & " bytes of data:" & Chr(10) & Chr(10) sPing = sPing & "Time (ms) = " & vbTab & oRetStatus.ResponseTime & Chr(10) sPing = sPing & "TTL (s) = " & vbTab & vbTab & oRetStatus.ResponseTimeToLive End If Next End Function Sub TestPing() MsgBox sPing("scriptorium.serve-it.nl") End Sub
User comments : |
| Add a new comment | Back to Top |

