使用命令行禁用以太网连接?

Com*_*mms 4 windows command-line batch-file

我见过许多'使用命令行禁用无线'帖子,但没有关于禁用以太网的帖子.

是否可以这样做(在Windows 7,32和64位上)?

Rap*_*tor 10

在Windows 7中,您可以使用

wmic path win32_networkadapter where NetConnectionID="Local Area Connection" call disable
wmic path win32_networkadapter where NetConnectionID="Local Area Connection" call enable
Run Code Online (Sandbox Code Playgroud)

即使在更多细节(启动提升命令提示符):

获取NIC列表和索引号

wmic nic get name, index
Run Code Online (Sandbox Code Playgroud)

启用带索引号的NIC(例如:7)

wmic path win32_networkadapter where index=7 call enable
Run Code Online (Sandbox Code Playgroud)

禁用带索引号的NIC(例如:7)

wmic path win32_networkadapter where index=7 call disable
Run Code Online (Sandbox Code Playgroud)

这是Windows XP中的命令:

netsh interface set interface name="Local Area Connection" admin=disabled
Run Code Online (Sandbox Code Playgroud)

如果网络名称不是"本地连接",请替换为您正在使用的名称.

参考:http://answers.microsoft.com/en-us/windows/forum/windows_7-hardware/enabledisable-network-interface-via-command-line/17a21634-c5dd-4038-bc0a-d739209f5081