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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:24:11  来源:igfitidea点击:

Disable network connection using batch file

windowsbatch-filenetworking

提问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.

我不确定您使用的是哪个版本的 Windows,但这里有适用于 XPnetsh 文档,可以帮助您入门。

回答by Dr. belisarius

You may use devcon(from MS).

您可以使用devcon(来自 MS)。

Usage

用法

  devcon disable *INTERFNAME    

Hereis a simple tutorial for your intended usage.

是您预期用途的简单教程。

HTH!

哼!

回答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