2015-02-23 54 views
0

我正在尝试使用批处理脚本来识别无线适配器的名称(人们将其重命名)。然后使用答案重新启动该适配器。有没有办法断开/重新连接一个更容易的特定配置文件?识别无线适配器名称和管道命令

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 

回答

0

检查下一个脚本(其中操作命令ECHO编仅用于调试目的)

@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 
) 

注:

  • %%a变量名是大小写敏感的;
  • and netconnectionid like '%wi%'wmic中省略,如您所述...... (人们更名)自己。