Sometimes you need to know your Windows machine’s IP. For example, if you would like to update your dynamic DNS entry from a script file. Here’s a hack that gets the job done.
This is from someone good with windows scripts, updated with some extra ‘shifts’ to get it to work under XP. Check out the link for an explanation. Save this in a batch file, I call mine ‘GetIP.bat’:
:: Script from: http://www.ericphelps.com/batch/samples/ip.txt @echo off cd %temp% :: Make a line fragment "temp.txt" echo e 100 "call temp2.bat "> script echo rcx>> script echo f>> script echo n temp.txt>> script echo w>> script echo q>>script debug < script > junk del script :: Make the working file "temp2.bat" echo shift> temp2.bat echo shift>> temp2.bat echo shift>> temp2.bat echo shift>> temp2.bat echo shift>> temp2.bat echo shift>> temp2.bat echo set IP=%%9>> temp2.bat :: Run the command that finds the IP and create "temp1.bat" copy temp.txt temp1.bat > junk ipconfig.exe | find "IP Address" | find /v " 0.0.0.0" >> temp1.bat :: Run the temp1.bat, which runs temp2.bat, which sets the IP variable call temp1.bat :: Remove temporary files del temp1.bat del temp2.bat del temp.txt del junk :: Display the result echo Your IP is %IP% pause