Skip to main content

AccessTr.neT


Sorgu İçerisindeki Verileri Tek Tek Kontrol Etme

Sorgu İçerisindeki Verileri Tek Tek Kontrol Etme

#2
'Test stub
Sub TestPing()
Dim strComputer As String
strComputer = "<target computer>"
If Not SystemOnline(strComputer) Then
MsgBox "This computer is currently unreachable: " & strComputer, vbOKOnly, "Computer Status"
'....your logic
Else
'...your logic
MsgBox "This computer is Online!", vbOKOnly, "Computer Status"
End If
End Sub 'TestPing



'Determine if device is online
Function SystemOnline(ByVal ComputerName As String)
Dim oShell, oExec As Variant
Dim strText, strCmd As String
strText = ""
strCmd = "ping -n 3 -w 1000 " & ComputerName
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec(strCmd)
Do While Not oExec.StdOut.AtEndOfStream
strText = oExec.StdOut.ReadLine()
If InStr(strText, "Reply") > 0 Then
SystemOnline = True
Exit Do
End If
Loop
End Function
Function SystemOnline(ByVal ComputerName As String)
' This function returns True if the specified host could be pinged.
' HostName can be a computer name or IP address.
' The Win32_PingStatus class used in this function requires Windows XP or later.
' Standard housekeeping
Dim colPingResults As Variant
Dim oPingResult As Variant
Dim strQuery As String
' Define the WMI query
strQuery = "SELECT * FROM Win32_PingStatus WHERE Address = '" & ComputerName & "'"
' Run the WMI query
Set colPingResults = GetObject("winmgmts://./root/cimv2").ExecQuery(strQuery)
' Translate the query results to either True or False
For Each oPingResult In colPingResults
If Not IsObject(oPingResult) Then
SystemOnline = False
ElseIf oPingResult.StatusCode = 0 Then
SystemOnline = True
Else
SystemOnline = False
End If
Next
End Function
Yurtdışı forumlarda bu kodlar ile yapmışlar.
AccessTr.Net teknik konular içeren bir sitedir. Bu tip sitelerde en iyi şekilde yardım alabilmeniz için Site Kurallarını mutlaka okumanız ve buna göre hareket etmeniz lazım.
Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da

Bu Konudaki Yorumlar
Cvp: Sorgu İçerisindeki Verileri Tek Tek Kontrol Etme - Yazar: alpeki99 - 22/03/2018, 15:08
Task