Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

External IP Address with VBScript 1

Status
Not open for further replies.
Dec 6, 2001
67
0
0
JM
I wish to get my external IP addresses from remote PCs on dynamic adsl programatically, i.e., stored in a text file. Then I could email or use MSN Messenger to get the info so I can logon. There are various websites that can give you the IP address ( for example.

How do you read in a website with VBScript/WSH?
 
You can read it using the InternetExplorer.Application or XMLHTTP. I posted something that does this, but don't remember where. I'll see if I find it.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Found it...

Code:
Option Explicit

WScript.Echo GetWANIP

Function GetWANIP
	On Error Resume Next
	Const cstrShowMyIP = "[URL unfurl="true"]http://www.showmyip.com/xml/"[/URL]
	
	Dim objRemXML  :  Set objRemXML = CreateObject("Microsoft.XMLDOM")
	objRemXML.async = False
	objRemXML.load(cstrShowMyIP)
	If Err.Number <> 0 Then
		WScript.Echo "Error getting IP address from " & cstrShowMyIP
		WScript.Quit
	End If
	
	' Get our IP address
	Dim objMyIP  :  Set objMyIP = objRemXML.selectSingleNode("/ip_address/ip")
	If Err.Number <> 0 Then
	  WScript.Echo "Error getting IP address from XML data"
	  WScript.Quit
	Else
	  GetWANIP = objMyIP.text
	End If
	On Error GoTo 0
End Function

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top