windows 使用命令行禁用以太网连接?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19021466/
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
Disabling ethernet connection with command line?
提问by Comms
I have seen many 'disable wireless with command line' posts, but not about disabling ethernet.
我看过很多“用命令行禁用无线”的帖子,但不是关于禁用以太网的。
Is it possible to do so (on Windows 7, 32 & 64 bit)?
是否可以这样做(在 Windows 7、32 和 64 位上)?
回答by Raptor
In Windows 7, you can use
在 Windows 7 中,您可以使用
wmic path win32_networkadapter where NetConnectionID="Local Area Connection" call disable
wmic path win32_networkadapter where NetConnectionID="Local Area Connection" call enable
Even in more details ( Start elevated Command Prompt ):
甚至更详细(启动提升的命令提示符):
Get NIC list and index number
获取网卡列表和索引号
wmic nic get name, index
Enable NIC with index number (eg: 7)
使用索引号启用 NIC(例如:7)
wmic path win32_networkadapter where index=7 call enable
Disable NIC with index number (eg: 7)
禁用带有索引号的 NIC(例如:7)
wmic path win32_networkadapter where index=7 call disable
Here is the command in Windows XP:
这是 Windows XP 中的命令:
netsh interface set interface name="Local Area Connection" admin=disabled
If the network name is not "Local Area Connection", substitute with the one you're using.
如果网络名称不是“本地连接”,请替换为您正在使用的名称。
参考:http: //answers.microsoft.com/en-us/windows/forum/windows_7-hardware/enabledisable-network-interface-via-command-line/17a21634-c5dd-4038-bc0a-d739209f5081
回答by foxidrive
To temporarily disable it you could use this:
要暂时禁用它,您可以使用它:
ipconfig /release local*3
if your connection was called "Local Area Connection 3"
如果您的连接被称为“本地连接 3”
回答by philip
if you want to disable network automatically on shutdown for windows 7 64bit
如果您想在 Windows 7 64bit 关机时自动禁用网络
use notepad type the disable command line from Raptor's answer above and save it as a .bat file
使用记事本在上面 Raptor 的回答中键入禁用命令行并将其保存为 .bat 文件
Run gpedit.msc and go to...computer configuration,windows settings,scripts,shutdown
运行 gpedit.msc 并转到...计算机配置、Windows 设置、脚本、关机
double click on "shutdown", click on "show files", paste the .bat file in the popup folder. click on add to add the .bat file.
双击“关机”,单击“显示文件”,将 .bat 文件粘贴到弹出文件夹中。单击添加以添加 .bat 文件。
:)
:)