获取本地终端电脑有线和无线的IP

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取本地终端电脑有线和无线的IP相关的知识,希望对你有一定的参考价值。

On Error Resume Next
Dim WshNetwork,con
dim regex,matches

serverIP = Wscript.Arguments(0)
serverDB = Wscript.Arguments(1)
serverUSer = Wscript.Arguments(2)
serverPW = Wscript.Arguments(3)

ConStr = "driver={sql server};Server=" + serverIP + ";Database=" + serverDB + ";uid=" + serverUSer + ";pwd=" + serverPW +";"

set regex = new regexp
pattern = "^.*] "
regex.pattern = pattern

Set WshNetwork = WScript.CreateObject("WScript.Network")
computername = WshNetwork.ComputerName

str = "insert into ipaddress values "

while 1 <> 0
set con = wscript.CreateObject("ADODB.Connection")
con.Open ConStr
command = "delete from ipaddress where computername = ‘" + computername + "‘"
con.Execute(command)

If con.State <> 0 Then
    Set wmiService = GetObject("winmgmts:\.
ootcimv2")

    Set Items = wmiService.ExecQuery("Select * From Win32_NetworkAdapter")

    command = ""
    For Each objItem in Items
        If LCase(Left(objItem.PNPDeviceID, 4))="pci" Then
            Set Its = wmiService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration where Caption=‘"& objItem.Caption &"‘")
            For Each It in Its
                If not IsNull(It.MACAddress) Then
                    If not IsNull(It.IPAddress) Then
                        CurrentTime=Year(Now)&"-"&Month(Now)&"-"&day(Now)&" "&Hour(Now)&":"&Minute(Now)&":"&Second(Now)
                        ipAddress = It.IPAddress(0)   
                        nicName = It.Caption
                        nicName = regex.replace(nicName,"")
                        nicMac = It.MACAddress

                        command = str + "(‘"+ computername +"‘,‘" + nicMac +"‘,‘" + ipAddress +"‘,‘" + currenttime  +"‘,‘" + nicName +"‘)"
                        con.Execute(command)    
                    End If
                End If
            Next
        End If
    Next
End If 

con.Close()
WScript.Sleep 10 * 60 * 1000 

wend

以上是关于获取本地终端电脑有线和无线的IP的主要内容,如果未能解决你的问题,请参考以下文章

平板电脑连接有线网络,IP地址怎么获取?把家里台式的网线拿来用可以吗?

无线网卡ip地址全为0怎么办?

笔记本电脑连wifi然后通过有线网口做桥接

virtualBox中有线和无线两种情况下centos虚拟机和本地机互ping的方案

电脑ip无网络访问权限怎么办

无线数传模块DTU终端