QTP的那些事--VBS获得本地连接的IP地址

代码如下:

Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("ipconfig.exe")
Set oStdOut = oExec.StdOut
ip = ""
Do Until oStdOut.AtEndOfStream
    strLine = oStdOut.ReadLine
    If InStr(strLine, "本地连接") > 0 Then
        strLine = oStdOut.ReadLine
        strLine = oStdOut.ReadLine
        strLine = oStdOut.ReadLine
        ip = Mid(strLine, InStr(strLine, ":") + 2)
        Exit Do
    End If
Loop

If ip = "" Then
    MsgBox "获取本地连接IP地址失败!", vbExclamation, "错误"
Else
    MsgBox ip, vbExclamation, ip
End If
posted @ 2012-02-16 20:19  高级测试开发网  阅读(619)  评论(0编辑  收藏  举报
了解开发资源最新动态:https://seniortesting.club