I have looked around and cant seem to find an in house windows version independent solution to getting the ip address of a computer in a batch file. What I would like to do is, no matter what windows machine I am on (whether its running win 7 or XP or maybe even 98) I would like to be able to figure out the ip address and store it into a variable in an easy fashion.
I can use ipconfig and parse out the IPv4 address but windows 7 outputs something slightly different than earlier versions so I would first have to figure out what version of windows they have and then look for the appropriate string. Any help would be great!
XP Pro / Vista / 7 / 8:
For Windows XP and newer I would recommend using
WMIC
.98 / 2000 / XP Home:
Other Commands
netsh interface ip show addresses
nbtstat -n | find "IpAddress:"
I guess this would do it:
Get your real internet IP Windows version independent with GNU wget
This works fine with
windows 10
Returns both
public
andprivate IP