使用VBScript查找计算机的IP地址

时间:2010-05-25 11:52:44

标签: vbscript

如何使用VBScript查找计算机的IP地址?

1 个答案:

答案 0 :(得分:1)

此示例显示了已配置的ip和计算机名称:

dim NIC1, Nic, StrIP, CompName

Set NIC1 =     GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")

For Each Nic in NIC1

    if Nic.IPEnabled then
        StrIP = Nic.IPAddress(0)

        Set WshNetwork = WScript.CreateObject("WScript.Network")
        CompName= WshNetwork.Computername

        MsgBox "IP Address:  "&StrIP & vbNewLine _
            & "Computer Name:  "&CompName,4160,"IP Address and Computer Name"

        wscript.quit
    End if
Next
相关问题