Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Does anyone have a script on emailing a public IP address whenever it changes, for WINDOWS? Possibly something that I can set up a schedualed task to run.

I am not a coder/scripter but I would like to get into it for automation purposes. Im a smart guy and I adapt well with new concepts but I am more trained on the network admin side of things (yet Im stuck in a software support desk job). So, if I sound out of place or ignorant let me know but I would appreciate the help.

I have read plenty of articles on people wanting the same script as me but they are always some kind of Bash script. I put Suse on a virtual box on my server at home but I can't seem to get the bash script to work (frankly, I would rather have a windows script or batch file to run). I have a forwarder set up on my router so that I can remote in from where ever, but my dynamic IP changes often. I know I can set up a free domain to manage this but Im to interested on getting this to work because it is just more fun.

Im a newby, so be descriptive please.

Thanks
Posted

1 solution

Someone wrote this up for me and it works great as a batch file. You just need to modify the email line and make sure you have cURL.exe and Blat.exe installed on your machine(cURL is used to grab the public IP off of the website and Blat is used to send the email). I hope someone finds this useful.

By the way... I put the pauses in so I could see why it wasnt working for me (i saw that i didnt have curl and blat installed).


@echo off
echo Checking External IP Address
if exist ip.current del ip.current
curl --insecure https://secure.internode.on.net/webtools/showmyip?textonly=yes >> ip.current
if not exist ip.old goto noold
set /p ipold= <ip.old
echo Stored IP found (%ipold%)
pause
goto checkold
:noold
ren ip.current ip.old
set /p ipcurrent= <ip.old
echo No Stored IP Found. Saving Current IP (%ipcurrent%)
pause
goto sendnote
:checkold
if %ipold% == %ipcurrent% goto nonote
echo IP Address has changed
pause
goto sendnote
:nonote
echo IP Address has not changed
del ip.current
pause
goto endscript
:sendnote
del ip.current
ren ip.current ip.old
blat.exe -f FROM@YOUR-EMAIL-ADDRESS.COM -t TO@YOUR-EMAIL-ADDRESS.COM -s "IPChange" -server YOUR-SMTP-SERVER-ADDRESS -body "%ipcurrent%"
echo Sent Email Notice
pause
:endscript
echo Script Complete
pause
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900