如何在Windows bat中获取某些适配器的默认网关?

请参阅下面的 windows中的ipconfig输出.
C:>ipconfig

Windows IP Configuration


Ethernet adapter Local Area Connection 11:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::4149:4c25:692d:dfec%91
   IPv4 Address. . . . . . . . . . . : 10.252.26.84
   subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

Wireless LAN adapter Wireless Network Connection 15:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Ethernet adapter Local Area Connection 10:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Wireless LAN adapter Wireless Network Connection 14:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::79a2:afc8:7cd0:79ac%72
   IPv4 Address. . . . . . . . . . . : 192.168.10.9
   subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.10.1

我想在bat文件中找到无线网络连接的认网关14,然后将其存储在varient中以便稍后使用

我知道我可以“findstr”,但我不知道如何获得该NIC的认网关.

谢谢!

验证接口名称
netsh interface ip show address

并尝试这样的事情:

@echo off

for /f "tokens=2 delims=:" %%g in ('netsh interface ip show address 
"Wireless Network Connection 14" ^| findstr "Default"') do 
set DefaultGateway=%%g
echo %DefaultGateway%
pause

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...