[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1019
  • Last Modified:

VBScript VPN IP Address

Hi,

I was hoping someone could maybe help me with a problem I have.  Essentially i am trying to write a script that gets the current IP address of my computer and saves it to a line in an existing file.  The problem is my computer is connected via a VPN and the current code I use to get the IP address does not return this IP address.

This is the curretn ipconfig info

==============================================

Windows 2000 IP Configuration

Ethernet adapter Local Area Connection 3:

      Connection-specific DNS Suffix  . :
      IP Address. . . . . . . . . . . . : 10.97.34.138
      Subnet Mask . . . . . . . . . . . : 255.255.240.0
      Default Gateway . . . . . . . . . : 10.97.34.138

Ethernet adapter Local Area Connection:

      Connection-specific DNS Suffix  . : blah.com
      IP Address. . . . . . . . . . . . : 10.0.5.82
      Subnet Mask . . . . . . . . . . . : 255.0.0.0
      Default Gateway . . . . . . . . . : 10.0.0.1

==============================================

The script is use always returns the "Ethernet adapter Local Area Connection" IP value of 10.0.5.82.  I need the other one.

Thanks in Advance.

James
0
phuzzy
Asked:
phuzzy
  • 3
  • 2
1 Solution
 
EDDYKTCommented:
which one do you like? 10.97.34.138?
0
 
phuzzyAuthor Commented:
Yes.
0
 
EDDYKTCommented:
Set objShell = WScript.CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec("%comspec% /c ipconfig.exe")

Do Until objExecObject.StdOut.AtEndOfStream
 strLine = objExecObject.StdOut.ReadLine()
 strIP = Instr(strLine,"IP Address")
 If strIP <> 0 Then
 Wscript.Echo strLine
 End If
Loop
0
 
phuzzyAuthor Commented:
Hmmm,

Yes and no.

I have had that idea how do we know that the VPN client IP will always be the first IP that loop would encounter?  It's a good idea but this script will be run on about 3 or 4 computers and i con't guarentee this would work 100%
0
 
phuzzyAuthor Commented:
Tweaked it a bit and yeah it will make do for now.

Thanks a million
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now