I'm attempting to have cmd copy only a specific set of character from a command output. I've been able to select the line that the phrase exists in but from there I am lost. Here is my command so far.
ipconfig | findstr /i "ipv4"
I'm sure you are familiar with the ipconfig command and the findstr command. Basically I'm isolating the IPv4 address of the specific computer.
This is what the above command.
IPv4 Address. . . . . . . . . . . : 192.168.1.75
I'd like to isolate "192.168.1." and have that saved to a variable to be used much later in a command. Say that I set "192.168.1." to variable a.
The next command I wish to run scans all IP addresses from 192.168.1.1 to 192.168.1.254 and save whichever are being used. As this, soon to be program, will be run on different computers at various locations the "192.168.1." will be different and I'm looking to isolate whatever cmd puts in it's location. So the aforementioned variable a could be but is not limited to, 192.168.10., 10.10.10., or even 1.1.1. depending on the situation. Here is the code I will be using.
FOR /L %i IN (1,1,254) DO ping -n 1 (the 'a' variable)%i | FIND /i "bytes=">>c:\ipaddresses.txt
or if seeing what the variable will look like helps.
FOR /L %i IN (1,1,254) DO ping -n 1 192.168.1.%i | FIND /i "bytes=">>c:\ipaddresses.txt
I am using a 64 bit windows 10 pro machine.