首页WIN11问题vb调用ping命令检测网络

vb调用ping命令检测网络

时间2022-12-05 09:15:26发布分享专员分类WIN11问题浏览71

添加一个textbox控件 代码如下:运行即可得到目的

Public Function CmdPing(ByVal strIp As String) As String

Dim p As New Process '创建一个线程

***.s断率事报tartInfo.FileNa来自me = "cmd.exe"

***.startInfo.UseShellExecute = False

***.sta360问答rtInfo.Redire盾输关乡载双希各ctStandardInput = True

***.startInfo.RedirectStanda式组么析rdOutput = True

***.startI突怕约nfo.Redir地抗于商刘获力报ectStandardError = True

***.startInfo.CreateNoWindow = Tru极古属e

Dim pingrst As String

***.start()

p.***.writeline("ping -n 1 " + strIp)

p.***.writeline("exit")

Dim strRst As String = p.***.readtoend()

If (***.indexof("(0% loss)") <> -1) Then

pingrst = "连接成功"

ElseIf (***.indexof("Destination host unreachable.") <> -1) Then

pingrst = "无法到达目的主机"

ElseIf ((***.indexof("Request timed out.") <> -1) Or (***.indexof("(100% loss)") <> -1)) Then

pingrst = "超训热吸时"

ElseIf (***.indexof("Unknown host") <> -1) Then

pingrst = "无法解析主机"

E食员协吧两一环lse

pingrst = strRst

End If

***.close()

Return pingrst

vb调用ping命令检测网络

End Function

Private Sub Form1_Load(ByVal sender As Object, ByVal e As ***.eventargs) Handles ***.load

Dim ip As String = ""

D项难做固队氧若右神负滑im strRst As S进轮布响tring = CmdPin例层波食州娘伟g(ip)

***.text = strRst

End Sub

爱资源吧版权声明:以上文中内容来自网络,如有侵权请联系删除,谢谢。

pingpinguseshellexecute
联想夺笋 App 今日上线:支持安卓/iOS,帮用户解决各类电脑问题 请教一个WMI远程执行命令的问题,万分