Reputation: 194
I'm trying to use a batch script to identify the name of the wireless adapter (people rename them). then use the answer to restart that adapter. Is there a way to disconnect/reconnect with a specific profile that would be easier?
for /f "usebackq tokens=* skip=1" %%a in ('wmic.exe nic where "NetConnectionStatus=2 and netconnectionid like '%wi%'" get NetConnectionID') do output=%%A
netsh interface set interface name=%%A admin=disabled
netsh interface set interface name=%%A admin=enabled
Upvotes: 0
Views: 753
Reputation: 30153
Check next script (where operational commands are ECHO
ed for debugging purposes only)
@echo OFF
for /f "tokens=2* delims==" %%a in (
'wmic.exe nic where "NetConnectionStatus=2" get NetConnectionID /value'
) do (
ECHO netsh interface set interface name="%%a" admin=disabled
ECHO netsh interface set interface name="%%a" admin=enabled
)
Note:
%%a
variable name is case sensitive;and netconnectionid like '%wi%'
omitted in wmic
filter as you stated …(people rename them) yourself.Upvotes: 1