我正在尝试创建一个.bat文件,可以启用/禁用我的以太网适配器,但我对编码或 cmd 语法没有太多了解。我正在考虑使用netsh命令如下:
IF " ~Ethernet adapter is enabled~ " GOTO :disable ELSE GOTO :enable
:disable
netsh interface set interface "Ethernet" disabled
:enable
netsh interface set interface "Ethernet" enabled
我怎样才能做对呢?
在上面的解决方案中,它会断开和连接互联网连接,因此我像这样即兴发挥来切换启用和禁用以太网适配器,这对我来说非常有效。
如果适配器已启用,此代码将禁用它;如果适配器已禁用,则此代码将启用它。
netsh interface show interface "Ethernet" |find "Disabled" >nul && (
echo disabled - enabling...
netsh interface set interface "Ethernet" enabled
) || (
echo enabled - disabling
netsh interface set interface "Ethernet" disabled
)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)