5
5
5napdragon2020-12-19 18:19:54
Computer networks
5napdragon, 2020-12-19 18:19:54

How to get a list of available networks via bat?

So, I have a bat (which I didn’t write myself), it displays a list of connected networks in another program, but I need it to display a list of all available for connection via:

Enable-NetAdapter
или
netsh interface set interface "Ethernet" enable


The bat source itself:
@echo off

setlocal enabledelayedexpansion
set /A COUNTER=0
set IFACE=
set IFACE_IP=
echo.

del net.txt
del NETS.txt
del res.txt

FOR /F "usebackq skip=2 delims=" %%a IN (`netsh interface show interface`) DO (
  FOR /F "tokens=3* delims= " %%b IN (^"%%a^") DO (
    set /A COUNTER+=1
    set IFACE=%%c
    FOR /F "usebackq skip=5 tokens=5 delims= " %%d IN (`netsh interface ipv4 show ipaddresses ^"!IFACE!^" normal`) DO (
      set IFACE_IP=%%d
      echo !COUNTER! - !IFACE!
      echo !IFACE! >> NETS.txt

    )
  )
)

wmic.exe nic where "NetConnectionStatus=2" get NetConnectionID |more +1 > net.txt
findstr /vrc:"^$" net.txt > res.txt

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question