0

Is it possible to use VBScript or commandline to grab the server IP of a PPP VPN under Windows?

alt text

Note this is not VPN dialup server IP.

est
  • 11,429
  • 14
  • 70
  • 118

1 Answers1

1

You can use VBScript to get the information from WMI. There are plenty of networking scripts here.
For example, use the following script to get the IP of a given net adapter. Just be sure to provide your VPN's name instead of the "Local Area Connection 2" string:

strComputer = "."
Set objWMIService = GetObject(_
    "winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapter " _
        & "Where NetConnectionID = " & _
        "'Local Area Connection 2'")

For Each objItem in colItems
    strMACAddress = objItem.MACAddress
Next

Set colItems = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration")

For Each objItem in colItems
    If objItem.MACAddress = strMACAddress Then
        For Each strIPAddress in objItem.IPAddress
            Wscript.Echo "IP Address: " &  strIPAddress
        Next
    End If
Next
Traveling Tech Guy
  • 27,194
  • 23
  • 111
  • 159
  • thank you, but the server IP as shown in the image is dynamically assigned, and looks like it can not be retrieved from WMI. – est Nov 09 '09 at 07:09
  • This code retrieves the current IP, as in "dynamically assigned". Did you try it? If it doesn't work, there are a couple of other WMI classes you could try - see the article. – Traveling Tech Guy Nov 09 '09 at 08:38
  • @Traveling Tech Guy, Yes your script got the client IP, but not the server IP. – est Nov 28 '09 at 14:01