VBS 剪切字符串的第一行

VBS cut first line of String

我有以下 Visual Basics 代码片段:

Option Explicit
Dim objshell, strCmd, objExec, strLine, strIP

set objShell = CreateObject("Wscript.Shell")

strCmd = "%comspec% /c nslookup LT1130"
Set objExec = objShell.Exec(strCmd)
Do Until objExec.StdOut.AtEndOfStream
    strLine = objExec.StdOut.ReadLine()
    If (Left(strLine, 8) = "Address:") Then
        strIP = Trim(Mid(strLine, 11))
        Wscript.Echo strIP
    End If
Loop

输出 2 行。第一行是我的 DNS 服务器的 IP 地址,第二行是解析后的 IP 地址。

如何剪切包含我的 DNS 服务器 IP 地址的第一行,只输出包含已解析 IP 地址的第二行?

(如果可能,不使用临时文本文件)

刚刚在我这边测试了这个修改后的代码,它有效 5/5


Option Explicit
Dim objshell, strCmd, objExec, strLine, strIP ,CountLine,MyArrayLine
set objShell = CreateObject("Wscript.Shell")
CountLine = 0
strCmd = "%comspec% /c nslookup myip.opendns.com. resolver1.opendns.com |find ""Address:"""
Set objExec = objShell.Exec(strCmd)
Do Until objExec.StdOut.AtEndOfStream
    strLine = objExec.StdOut.ReadLine()
    CountLine = CountLine + 1
    If Instr(strLine,":") > 0 Then
        MyArrayLine = Split(strLine,":")
        strIP = Trim(MyArrayLine(1))
        If CountLine = 2 Then
            Wscript.Echo "My External IP Address : " & strIP
        End If
    End If
Loop