Option Explicit Dim dtmStart, lngSeconds WScript.Echo "Comparing 3 ways to retrieve your WAN IP address:" & vbCrLf dtmStart = Now WScript.Echo "InternetExplorer.Application " _ & MyIP_IE( ) & " (" _ & DateDiff( "s", dtmStart, Now ) & " seconds)" dtmStart = Now WScript.Echo "Microsoft.XMLHTTP " _ & MyIP_XMLHTTP( ) & " (" _ & DateDiff( "s", dtmStart, Now ) & " seconds)" dtmStart = Now WScript.Echo "WinHttp.WinHttpRequest.5.1 " _ & MyIP_WinHTTP( ) & " (" _ & DateDiff( "s", dtmStart, Now ) & " seconds)" Function MyIP_IE( ) ' Name: MyIP_IE ' Function: Display your WAN IP address using Internet Explorer ' Usage: ret = MyIP_IE( ) ' Returns: WAN (or global) IP address ' ' This script uses WhatIsMyIP.com's automation page ' http://www.whatismyip.com/automation/n09230945.asp ' ' Written by Rob van der Woude ' http://www.robvanderwoude.com Dim blnTimedOut, i, objIE, objMatch, objRE, strText, strURL ' Return value if IP address couldn't be retrieved MyIP_IE = "0.0.0.0" ' Open the appropriate URL in Internet Explorer strURL = "http://automation.whatismyip.com/n09230945.asp" Set objIE = CreateObject( "InternetExplorer.Application" ) objIE.Visible = False objIE.Navigate2 strURL ' Wait till IE is ready i = 0 blnTimedOut = False Do While objIE.Busy WScript.Sleep 100 i = i + 1 ' Time out after 10 seconds If i > 100 Then blnTimedOut = True Exit Do End If Loop ' Retrieve the URL's text If Not blnTimedOut Then MyIP_IE = objIE.Document.Body.InnerText ' Close the Internet Explorer session objIE.Quit Set objIE = Nothing End Function Function MyIP_XMLHTTP( ) ' Name: MyIP_XMLHTTP ' Function: Display your WAN IP address using XMLHTTP ' Usage: ret = MyIP_XMLHTTP( ) ' Returns: WAN (or global) IP address ' ' This script uses WhatIsMyIP.com's automation page ' http://www.whatismyip.com/automation/n09230945.asp ' ' Original script written in JScript by Isaac Zelf ' "Translated" to VBScript by Rob van der Woude ' http://www.robvanderwoude.com Dim objRequest, strURL ' Return value in case the IP address could not be retrieved MyIP_XMLHTTP = "0.0.0.0" ' Retrieve the URL's text strURL = "http://automation.whatismyip.com/n09230945.asp" Set objRequest = CreateObject( "Microsoft.XMLHTTP" ) objRequest.open "GET", strURL, False objRequest.send vbNull If objRequest.status = 200 Then MyIP_XMLHTTP = objRequest.responseText Set objRequest = Nothing End Function Function MyIP_WinHTTP( ) ' Name: MyIP_WinHTTP ' Function: Display your WAN IP address using WinHTTP ' Usage: ret = MyIP_WinHTTP( ) ' Returns: WAN (or global) IP address ' ' This script uses WhatIsMyIP.com's automation page ' http://www.whatismyip.com/automation/n09230945.asp ' ' Written by Rob van der Woude ' http://www.robvanderwoude.com Dim lngStatus, objHTTP, objMatch, objRE, strText, strURL ' Return value in case the IP address could not be retrieved MyIP_WinHTTP = "0.0.0.0" ' Retrieve the URL's text strURL = "http://automation.whatismyip.com/n09230945.asp" Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" ) objHTTP.Open "GET", strURL objHTTP.Send ' Check if the result was valid, and if so return the result If objHTTP.Status = 200 Then MyIP_WinHTTP = objHTTP.ResponseText Set objHTTP = Nothing End Function