Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On a Windows 7 device, the following WMI query does not report back an enabled PPP adapter:

Select Index,MACAddress,IPAddress,IPSubnet,DefaultIPGateway,DNSServerSearchOrder from Win32_NetworkAdapterConfiguration where IPEnabled=true

Where ipconfig gives you all the information correctly:

Windows IP Configuration

PPP adapter XYZ VPN:

Connection-specific DNS Suffix . : IPv4 Address. . . . . . . . . . . : 123.456.789.123
Subnet Mask . . . . . . . . . . . : 255.255.255.255
Default Gateway . . . . . . . . . : 0.0.0.0

Wireless LAN adapter Wireless Network Connection:

Connection-specific DNS Suffix . : IPv4 Address. . . . . . . . . . . : 192.168.178.11
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.178.1

Ethernet adapter Local Area Connection 3:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :

Any ideas how I can script this by using WMI or VBS?

share|improve this question
    
Have you found a solution to this? I'm experiencing the same problem on Win7(x86). – AlexS Nov 13 '12 at 17:44

This is a bug that was present in Vista and hasn't gotten fixed through Windows 7 or Windows 8.

You must use either .NET or C++ APIs to get this information. I think the easiest thing to do is to use Powershell with .NET:

$nics = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()
foreach ($nic in $nics) {
    write-host $nic.name
    write-host "MAC Address $($nic.GetPhysicalAddress)"
    $props = $nic.GetIPProperties()
    $addresses = $props.UnicastAddresses
    foreach ($addr in $addresses) {
        write-host "IP Address: $($addr.Address.IPAddressToString)"
        write-host "IPv4 Mask: $($addr.IPv4Mask.IPAddressToString)"
    }
    write-host "Gateway: $($props.GatewayAddresses.Address.IPAddressToString)"
    write-host "DNS Server(s): $($props.DnsAddresses.IPAddressToString)"
    write-host ""
}

See the NetworkInterface class documentation for information on using that .NET class with C#, VB, or C++.

share|improve this answer
On Error Resume Next

strComputer= "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")

Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")

For Each objItem In colItems
      strIPAddress = Join(objItem.IPAddress, ",")

      WScript.Echo "IPAddress: " & strIPAddress

Next
share|improve this answer
    
This doesn't answer the question! – AlexS Nov 13 '12 at 17:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .