Main Problem:
The ECHO command ignores all characters before the token argument and inserts all text after the token argument before the token in the output:
Here's the script:
@ECHO OFF
FOR /F "USEBACKQ TOKENS=2 DELIMS==" %%a IN (`
WMIC NIC WHERE
"MACAddress IS NOT NULL"
GET
MACAddress
/FORMAT:LIST ^|
FINDSTR /V /R "^%"
`) DO (
ECHO [%%a]
ECHO 0123456789%%a9876543210
)
PAUSE > NUL
Here's the expected output:
[AA:BB:CC:11:22:33]
0123456789AA:BB:CC:11:22:339876543210
Here's the actual output:
]AA:BB:CC:11:22:33
9876543210AA:BB:CC:11:22:33
Why do I care?
My intention is to replace the DO () block in the example above with this block:
:: ...FOR LOOP STUFF...
`) DO (
WMIC NIC WHERE ^
"MACAddress=%%a" ^
GET ^
NetConnectionID ^
/FORMAT:LIST | FINDSTR /V /R "^$"
WMIC NICCONFIG WHERE ^
"MACAddress=%%a" ^
GET ^
DefaultIPGateway,^
DNSServerSearchOrder,^
IPAddress,^
IPSubnet,^
MacAddress ^
/FORMAT:LIST | FINDSTR /V /R "^$"
)
As described above, all characters before %%a get cut off and all characters after %%a show up before %%a when the script is processed. Somebody please help, I'm figuratively crying here.