我想获取存储在变量中的计算机的全局IPv6地址。
我找到了这段代码,但它只给出了Link-Local地址。
for /f "delims=[] tokens=2" %%a in ('ping %computername% -6 -n 1 ^| findstr "["') do (set ipv6=%%a)发布于 2016-07-19 20:35:34
在vbscript中,我们可以这样做:
获取OnlyIPv6Address.vbs
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration where IPEnabled = 'True'")
For Each objIP in colSettings
For i=LBound(objIP.IPAddress) to UBound(objIP.IPAddress)
If InStr(objIP.IPAddress(i),":") <> 0 Then msgbox objIP.IPAddress(i)
Next
Next并获取OnlyIPv4Address.vbs
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration where IPEnabled = 'True'")
For Each objIP in colSettings
For i=LBound(objIP.IPAddress) to UBound(objIP.IPAddress)
If InStr(objIP.IPAddress(i),":") = 0 Then Msgbox objIP.IPAddress(i)
Next
Nexthttps://stackoverflow.com/questions/38457792
复制相似问题