| 1. |
Solve : Search and copy? |
|
Answer» What I'm trying to find, is a way to search for a string of text that's outputted from a command, then COPY the next couple characters, and finally store them as a variable. Computer name \\LAPTOP Next use the find command to extract the line where the GUID resides: net config rdr | find /i "tcpip" Quote NetBT_Tcpip_{96C2160D-9E3B-4AE5-97CC-4B88AE6DB75F} (001150F4851B) Next use the for command to parse the resulting output: for /f "tokens=3 delims={}_" %i in ('net config rdr | find /i "tcpip"') do echo GUID: %i Quote GUID: 96C2160D-9E3B-4AE5-97CC-4B88AE6DB75F Finally, fix up the command for use in a batch file. Code: [Select]@echo off for /f "tokens=3 delims={}_" %%i in ('net config rdr ^| find /i "tcpip"') do echo GUID: %%i The for command uses a combination of arbitrary tokens, delimiters, and a starting point of sequential addressable variables to do the parsing. For instance, this version of the for would be equally correct: Code: [Select]@echo off for /f "tokens=2 delims={}" %%x in ('net config rdr ^| find /i "netbt"') do echo GUID: %%x Hmm, I'm not 100% sure of what the "for /f" and the "tokens=3 delims={}_" are for. Furthermore the "%i" variable is contained within the "for" command, and cannot be used outside. Again, thanks for your THOROUGH REPLIES! |
|