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.0Wireless 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.1Ethernet 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?
Best Answer
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:
See the NetworkInterface class documentation for information on using that .NET class with C#, VB, or C++.