trying to get a batch to output network adapter names for another batch file. so far this works...
@echo off
set ignore=true
for /F "delims=" %%a in ('netsh interface show interface')do call :Sub %%a
goto :eof
:sub
if not "%adapter1%" EQU "" goto :2
set Line=%*
if "%Line:~0,10%" EQU "----------" (set ignore=false & goto :eof)
if %ignore% EQU true goto :eof
for /F "tokens=4*" %%b in ('echo %*') do set Adapter1=%%b
echo %Adapter1%
goto :eof
)
:2
for /F "tokens=4*" %%c in ('echo %*') do set Adapter2=%%c
echo %adapter2%
pause
But is there a way to loop the second part so the output would continue with Adapter#="Adapter Name" until there are no adapters left.
I've tried to use..
set /a c=1
:sub
for /F "tokens=4*" %%c in ('echo %*') do (
set /a c=c+1
Set Adapter%c%=%%b
echo %adapter2%
)
couple of issues here trying to call a variable made of Variables ie.%adapter%c%%
and the other being i have no idea how to loop this back to the next line.
I realise i could keep expanding this but it would be horrendous.
@echo off
set ignore=true
for /F "delims=" %%a in ('netsh interface show interface')do call :Sub %%a
goto :eof
:sub
if not "%adapter2%" EQU "" goto :3
if not "%adapter1%" EQU "" goto :2
set Line=%*
if "%Line:~0,10%" EQU "----------" (set ignore=false & goto :eof)
if %ignore% EQU true goto :eof
for /F "tokens=4*" %%b in ('echo %*') do set Adapter1=%%b
echo %Adapter1%
goto :eof
)
:2
for /F "tokens=4*" %%c in ('echo %*') do set Adapter2=%%c
echo %adapter2%
pause
:3
for /F "tokens=4*" %%c in ('echo %*') do set Adapter3=%%c
echo %adapter3%
pause
Frustrated >.< , can't get my head around how its supposed to work. Any help appreciated. Thanks
for /F "skip=3 tokens=4*" %a in ('netsh interface show interface') do @echo %a
(try it from an opencmd
prompt)