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


本文转自hcy's workbench博客园博客,原文链接:http://www.cnblogs.com/alterhu/archive/2012/02/16/2354844.html ,如需转载请自行联系原作者。
目录
相关文章
|
网络协议 网络安全
SecureCRT远程端口转发不生效的解决方法
SecureCRT远程端口转发不生效的解决方法
463 0
SecureCRT远程端口转发不生效的解决方法
|
4月前
|
Linux 虚拟化
Linux虚拟机不显示IP地址的解决办法
Linux虚拟机不显示IP地址的解决办法
94 0
|
网络协议 Windows
使用BAT设置Windows系统的IP地址
系统环境使用windows10,版本1809(内部版本17763.379)
1627 0
window powershell 获取本机IP
[System.Net.Dns]::GetHostAddresses(_.AddressFamily -eq 'InterNetwork' } | Select-Object -ExpandProperty IPAddressToString ...
1422 0