I have an old script I used to use on Windows XP that walked the
network adapters, looked for a PPTP adapter, and applied a handful of
routes based on the IP that was assigned to that adapter. Ignoring
the reason this was done, it worked just fine on 2003, and XP. Basic
script looked like this:
====8<-------------------------------------------------------------------------
strComputer = "."
set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"
& strComputer & "\root\cimv2")
set adapters = objWMI.ExecQuery _
("select * from Win32_NetworkAdapterConfiguration where
IPEnabled = TRUE")
For Each adapter in adapters
adapterType = adapter.Description(0)
if InStr(adapterType, "PPP") then
IsRas = True
ipaddress = adapter.IPAddress(0)
End If
Next
{ add routes here }
====8<-------------------------------------------------------------------------
However, I'm finding two changes in behavior on Windows 7, and cannot
find any documentation to support the reasons behind it. The first is
that PPTP adapters no longer have the IPEnabled flag set to true.
Using a simple script in PowerShell to get the flags:
====8<-------------------------------------------------------------------------
$adapters = Get-WmiObject Win32_NetworkAdapterConfiguration
foreach ($adapter in $adapters) {
"Description = " + $adapter.Description
"IPEnabled = " + $adapter.IPEnabled
}
====8<-------------------------------------------------------------------------
Description = WAN Miniport (PPTP)
IPEnabled = False
Description = WAN Miniport (PPPOE)
IPEnabled = False
Even worse, when the VPN connection is established, the
Win32_NetworkAdapterConfiguration isn't updated with the IP address of
the connection.
ipconfig shows:
PPP adapter <masked>:
Connection-specific DNS Suffix . :
IPv4 Address. . . . . . . . . . . : 192.168.111.170
Subnet Mask . . . . . . . . . . . : 255.255.255.255
Default Gateway . . . . . . . . . :
Win32_NetworkAdapterConfiguration is showing this:
Description = WAN Miniport (PPTP)
IPEnabled = False
IP Address =
Description = WAN Miniport (PPPOE)
IPEnabled = False
IP Address =
No IPs. This obviously makes the original script useless.
Anybody got any ideas as to why the change? And the new method of
finding the IP on a PPTP adapter?
Thanks
--
Jonathan Angliss
<j...@netdork.net>