Get your External IP address in a batch process (command line)

If you are familiar with the frustration where you need your External IP address and the only way to do it (you think) is to open your browser and navigate to whatismyip or a similar, this post might do you good.

In this post, we will do several things:
1. We will learn how to create our own simple developing environment.
2. We will compile a very basic command line application (don’t worry I will provide the source)
3. We will use that new application for our needs (discover what is our external IP in a batch program - we will use those web sites but not in a browser)

So let’s begin,
Software we need:
a. Jens’ File Editor
b. BCX – Basic to C Translator/
c. LCC – C Compiler/
d. Source Files

After installing that precious software, let’s configure them to work with each other,
Open the JFE editor, add the BCX translator, LCC Compiler, LCC Linker buttons to it:
Go to “Settings --> Add tool”

JFE Editor - Settings - Add tool

Add those 3 tools:
BCX Button

LCC Compile Button

LCC Link Button

(Parameters for the link button:
"$PATH\$NAME.obj" -s -output:"$PATH\$NAME.exe" -subsystem:console wsock32.lib wininet.lib urlmon.lib shell32.lib)

For me, JFE looks like this (our small source code already opened in it):
JFE opened with the IPEX source in it

If you have not done it already, please open the source file IPEX.BAS
(Download the ZIP from here)

Take this great offer valid until 07/11/09

Microsoft Store

Now we will translate it to C source, just click the BCX button you have created earlier:
BCX Output Log at JFE

Drag your new “IPEX.C” file into JFE:
IPEX C Source opened at the JFE Editor

Click the “LCC Compile” button, verify no error at the log, and click the “LCC Link Con” button.

You should have the following files now:
Final File list after compile and link

All you have to do now is to use it:
IPEX Usage example at the command line

You can combine it with an email batch sending application (and maybe a schedule task) that will send you a message once a day with your home/office external IP (for dynamic IP’s) or any command line combination you want.




  1. Udi hi,

    i am one of your Blog fan's and this post was great as well as a useful tip.

    keep up the great work.


  2. This comment has been removed by a blog administrator.

  3. Good dispatch and this post helped me alot in my college assignement. Say thank you you on your information.

  4. the post has proved very helpful and i was wondering if it could be possible for it to show external ip only in command line,and can u write in c++ so we can have a better understanding as i am a newbee....

  5. Lesly,

    Just run it with a "/t" and it will give you only the IP address without any texts.

  6. The moment I saw this was like wow. Thank you for putting your effort in making this tutorial.