Getting external IP (Visual Basic)

Send Us a Sign! (Contact Us!)
Word PDF XPS Text

“How do I get my external ip?”

I get this question fairly often from family and coworkers. Easy answer, your [gs router]. But it’s not always handy to log in to your router just to get your actual IP address.

An easier way would be to write a simple [gs command line] [gs script]. But unless your router has some API functionality for returning an external IP your best bet for getting it is going to be to ping a bounce-back server like WhatIsMyIP

Here is a vbs script to do this automatically (myip.vbs):

With CreateObject("MSXML2.XMLHTTP")

.open "GET", "", False
WScript.Echo .responseText
End With

WhatIsMyIP has rules about using their automation service, namely don’t ping them more than once every 3 minutes. Well you can do what you want but they do seem to block successive attempts if you hammer their server.


But in order to use this little script you’d need to call cscript.exe from the command line like this: cscript.exe myip.vbs

That is unless you wrote a .bat/.cmd file (whatismyip.bat) to make the call:

::Display single line ip address using's public access point

@cscript //nologo myip.vbs

//nologo: suppresses cscripts logo.
@ before cscript: suppresses Windows batch command echo.




2 thoughts on “Getting external IP (Visual Basic)”

Comments are closed.