windows - How to get global IPv6 address via batch-file -
i want global ipv6 address of computer stored inside variable.
i found code, gives link-local address.
for /f "delims=[] tokens=2" %%a in ('ping %computername% -6 -n 1 ^| findstr "["') (set ipv6=%%a)
in vbscript can :
to onlyipv6address.vbs
strcomputer = "." set objwmiservice = getobject("winmgmts:" & "{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2") set colsettings = objwmiservice.execquery ("select * win32_networkadapterconfiguration ipenabled = 'true'") each objip in colsettings i=lbound(objip.ipaddress) ubound(objip.ipaddress) if instr(objip.ipaddress(i),":") <> 0 msgbox objip.ipaddress(i) next next
and onlyipv4address.vbs
strcomputer = "." set objwmiservice = getobject("winmgmts:" & "{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2") set colsettings = objwmiservice.execquery ("select * win32_networkadapterconfiguration ipenabled = 'true'") each objip in colsettings i=lbound(objip.ipaddress) ubound(objip.ipaddress) if instr(objip.ipaddress(i),":") = 0 msgbox objip.ipaddress(i) next next
Comments
Post a Comment