Imports System.Management
Imports System.Data.SqlClient
Imports System.Net
Imports System.Net.Mail
Imports System.IO
Partial Class any_kind_refer_pingIP
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Call Ping("C1012849807") 'ping 刷卡機
End Sub
Private Sub Ping(ByVal ip As String)
Dim o As Object, p As Object, s As Object
Dim i As Integer
Dim PtcAddr As String
Dim Pingtimes As Integer = 0
o = GetObject("winmgmts:{impersonationLevel=impersonate}")
For i = 0 To 3
p = o.ExecQuery("Select * From Win32_PingStatus Where Address = '" & ip & "'")
For Each s In p
If (s.StatusCode) <> Nothing Or s.StatusCode <> 0 Then
'Ping = "Computer " & ip & " is not reachable"
Pingtimes -= 1
Else '
PtcAddr = s.ProtocolAddress
'Ping = Ping() & vbCrLf & _
' "Bytes=" & s.BufferSize & " " & _
' "Time=" & s.ResponseTime & "ms " & _
' "TTL=" & s.ResponseTimeToLive
Pingtimes += 1
End If
Next
Next
If Pingtimes >= 1 Then '代表電腦有開機
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "javascript", "window.parent.frames(3).location='work.aspx'", True)
ElseIf Pingtimes <= 0 Then '代表電腦無開機
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "javascript", "window.parent.frames(3).location='errorweb.aspx'", True)
End If
'Ping = "Pinging " & ip & _
' IIf(ip = PtcAddr, "", " [" & PtcAddr & "] ") & vbCrLf & Ping
End Sub
End Class
Imports System.Data.SqlClient
Imports System.Net
Imports System.Net.Mail
Imports System.IO
Partial Class any_kind_refer_pingIP
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Call Ping("C1012849807") 'ping 刷卡機
End Sub
Private Sub Ping(ByVal ip As String)
Dim o As Object, p As Object, s As Object
Dim i As Integer
Dim PtcAddr As String
Dim Pingtimes As Integer = 0
o = GetObject("winmgmts:{impersonationLevel=impersonate}")
For i = 0 To 3
p = o.ExecQuery("Select * From Win32_PingStatus Where Address = '" & ip & "'")
For Each s In p
If (s.StatusCode) <> Nothing Or s.StatusCode <> 0 Then
'Ping = "Computer " & ip & " is not reachable"
Pingtimes -= 1
Else '
PtcAddr = s.ProtocolAddress
'Ping = Ping() & vbCrLf & _
' "Bytes=" & s.BufferSize & " " & _
' "Time=" & s.ResponseTime & "ms " & _
' "TTL=" & s.ResponseTimeToLive
Pingtimes += 1
End If
Next
Next
If Pingtimes >= 1 Then '代表電腦有開機
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "javascript", "window.parent.frames(3).location='work.aspx'", True)
ElseIf Pingtimes <= 0 Then '代表電腦無開機
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "javascript", "window.parent.frames(3).location='errorweb.aspx'", True)
End If
'Ping = "Pinging " & ip & _
' IIf(ip = PtcAddr, "", " [" & PtcAddr & "] ") & vbCrLf & Ping
End Sub
End Class