Thursday, July 16, 2009

How to email an external IP from a command line in Windows

Do you do remote support for customers, family and friends, that for some reason won't or can't get a dynamic DNS (available from for their dynamic IP? Here is a "simple" solution, using all free software. Once this is setup it will email you their IP every day, or whenever you tell them to click that shortcut I made for you.

Create a folder on their C:\ called GetIP

Extract all files from ( to the GetIP folder, you should have the following structure:

Install HFFRTAKSetup.exe, you should use all default options except you won't need the desktop or Quick Launch icons.

Edit GetIP.bat, change the SET commands to match you, the other person and your ISP.
Host = SMTP server of your ISP
Sender = Sender's full email address
Receiver = Recipient's full email address
User = User name for the SMTP account
Pw = Password for the SMTP account
Port = Outgoing mail port
Name = Friendly name of the person or company this is for

That is it for the setup. Since you are the person that does support, I won't insult your intelligence with detailed instructions for creating the scheduled task or setting up a desktop shortcut.

The major downside to this routine is that you have to place SMTP login information in the batch file in plain text.

The portion of this routine that gets the IP is based on the work done by basepart on Aug. 26, 2004 (

Labels: , , , , , , ,


At July 20, 2009 at 1:12 PM , Blogger AngelDeLaNoche said...

I had an idea on how to modify this routine so that you will only get a message when the address changes. Instead of scheduling the test to run every day, have it run every hour or every 10 minutes. Modify the batch file to output the current subject line to a text file:

echo %Subject% >t1.txt

Then compare that file to the previous file:

fc t0.txt t1.txt /b
if errorlevel 1 goto SendEmail
goto end

In the sendmail section, send the message:

[BLAT command]

Finally, in the END section, cleanup and prepare for the next check:

del t0.txt
ren t1.txt t0.txt

All of this would be placed in the batch file where the current BLAT command is located.

The downside to this of course would be that if you don't get an email you don't know if that is because their network is down or because it hasn't changed.

This could also be used as a poor man's monitor. When the emails stop, the communication to the server is lost.

At July 20, 2009 at 1:15 PM , Blogger AngelDeLaNoche said...

BTW, I have my junk mail filter set to automatically delete these incoming messages. When I actually need one, I go look it up in my deleted items.

At August 19, 2009 at 9:59 AM , Blogger AngelDeLaNoche said...

Oops. HFFRTAK is not freeware as I thought. It is only a trial version. Just rem out the lines that use it. All it did was some cleanup and was not necessary to the actual function of this routine.

At February 24, 2010 at 12:54 PM , Blogger AngelDeLaNoche said...

Update: I just replaced the download file with all the changes listed above. Follow the included Readme for correct installation procedures. This download also includes code to send to multiple recipients.

At May 26, 2011 at 11:39 AM , Anonymous Anonymous said...

Symantec and other anti-virus products will detect nc.exe as a hacktool. Netcat is no more an attack tool than any file transfer or remote access program. It does not exploit any vulnerability, contain any malicious code, or attempt to hide its presence. Netcat doesn't do anything except what you tell it to. Netcat is a legitimate very useful networking utility that unfortunately is sometimes installed by malicious programs to allow unauthorized remote access.


Post a Comment

Subscribe to Post Comments [Atom]

<< Home