Hello, I need some help. As the subject says, I want to get my public IP address in batch somehow and then export it to a file. This is the only thing I've found online, but it's giving me a wrong address, so it's not working (for me??):
Code: Select all
@Echo off
for /f "tokens=2 delims=: " %%A in (
'nslookup myip.opendns.com. resolver1.opendns.com 2^>NUL^|find "Address:"'
) Do set ExtIP=%%A
Echo External IP is : %ExtIP%
I do know that this just shows an IP, in order to save it we'd have to change this code a little bit, like this:
Code: Select all
@Echo off
for /f "tokens=2 delims=: " %%A in (
'nslookup myip.opendns.com. resolver1.opendns.com 2^>NUL^|find "Address:"'
) Do set ExtIP=%%A
Echo %ExtIP% > FileName.txt
However it doesn't matter since it just doesn't work. Any suggestions, please???