This is going to just be a quick post but hopefully thereās enough detail to get you going.
I needed a way to display just the IP address of a computer within a batch file. I accomplished this by using a combination of FOR, ipconfig, and find:
The heart of the command is ipconfig. Youāre probably familiar with it, but if youāre not it displays a bunch of IP related information for the computer youāre on. This includes the IP address.
The next part is find. This only outputs the lines that have a string match. Iām feeding it āIPv4ā as Iām using it in WinPE v3.1, which is Windows 7 based. In XP and older youād have to change āIPv4ā to āIP Addressā or something like that.
The for statement simply pulls out the correct part of the string and stores it in a variable called _IPAddress. This can then be echoed anywhere else in the batch file.