windows 使用批处理文件禁用网络连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3926309/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Disable network connection using batch file
提问by Delta
I need to enable/disable network connections on windows with a batch file.
我需要使用批处理文件在 Windows 上启用/禁用网络连接。
回答by egrunin
You can do this with Windows PowerShell. Here's a page with examples.
您可以使用 Windows PowerShell 执行此操作。这是一个带有示例的页面。
Probably you want to use the last one on that page.
可能您想使用该页面上的最后一个。
Update
更新
A little more searching reminded me about netsh, which is a more appropriate tool than either PowerShell or devcon:
更多的搜索让我想起了 netsh,它是一个比 PowerShell 或 devcon 更合适的工具:
netsh interface set interface "Local Area Connection " ENABLE
netsh interface set interface "Local Area Connection " DISABLE
I'm not sure which version of Windows you're using, but here's the netsh doc for XPto get you started.
回答by Dr. belisarius
回答by CMS_95
netsh wlan connect ssid=*SSID HERE*name= network name HEREinterface="Wireless Network Connection"
netsh wlan connect ssid=*SSID HERE*name=网络名称 HEREinterface="无线网络连接"
and
和
disconnect interface="Wireless Network Connection"
断开接口=“无线网络连接”
both actually work in windows 7
两者实际上都适用于 Windows 7