VBScript – Return IP and Gateway Addresses; Raw formats

email me

A simple way to return IP information is to use WMI.

On error resume next
'set computer name; uses local machine name
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem In colItems
  IPAddress = Join(objItem.IPAddress, ",")
  GatewayAddress = Join(objItem.GatewayAddress, ",")
  'output information
  MsgBox "IP Address = " & IPAddress & vbCrLf & "Gateway Address = " & GatewayAddress
Next