I'm trying to rename the NIC names on my PC. It has A LOT of NICs (they are virtual). I can get their names like so
for /f "tokens=2 delems==" %%A in ('wmic nic where "Description like 'foo'" get netconnection id /value') do (
echo %%A
)
I'd like to use netsh inside that loop to rename them. Unfortunately, the target names aren't simple incrementing numbers. So I did
set names[0]=name1
set names[1]=name two
set names[2]=name test
set local ENABLEDELAYEDEXPANSION
set /a idx=0
for /f "tokens=2 delems==" %%A in ('wmic nic where "Description like 'foo'" get netconnectionid /value') do (
echo names[!idx!]
set /a idx=!idx!+1
)
This outputs
names[0]
names[1]
names[2]
But if I try
set names[0]=name1
set names[1]=name two
set names[2]=name test
set local ENABLEDELAYEDEXPANSION
set /a idx=0
for /f "tokens=2 delems==" %%A in ('wmic nic where "Description like 'foo'" get netconnectionid /value') do (
echo %names[!idx!]%
set /a idx=!idx!+1
)
I just get garbage output. Is there some way I can evaluate the generated string in the previous example as a variable? Then I could pass that to netsh to do the renaming.