24

我知道在 Google 中存在大量结果:results,但我没有在我的 Windows XP 机器上找到它。我想从命令行禁用 LAN 连接。

>netsh interface set interface "Local Area Connection" DISABLED
One or more essential parameters not specified
The syntax supplied for this command is not valid. Check help for the correct sy
ntax.

>netsh interface set interface name="Local Area Connection" admin="disabled"
One or more essential parameters not specified
The syntax supplied for this command is not valid. Check help for the correct sy
ntax.

>netsh interface set interface name="Local Area Connection" admin=DISABLED
One or more essential parameters not specified
The syntax supplied for this command is not valid. Check help for the correct sy
ntax.
4

5 回答 5

24

对于前两个命令,您需要提升/管理员权限:

禁用 LAN 网络连接

C:\> netsh interface set interface name="Local Area Connection" admin=disabled

启用 LAN 网络连接

C:\> netsh interface set interface name="Local Area Connection" admin=enabled

假设:您的接口被命名为“本地连接”,否则替换为专有名称。用于netsh interface show interface查找名称。

列出 Wifi 配置文件

C:\> netsh wlan show profiles

连接到 Wifi 配置文件

C:\> netsh wlan connect name="ProfileName"
于 2014-09-23T06:27:41.250 回答
6

您必须以提升/管理员权限运行它。

(在 Windows 7 上,否则我会收到令人困惑的错误消息

An interface with this name is not registered with the router.

)

(我编辑了@yarish kumar 的答案以反映这一点。)

于 2015-05-31T08:47:59.143 回答
2

C:\WINDOWS\system32>netsh interface 显示界面

管理状态 状态类型 接口名称

已启用 已连接专用以太网 2 已启用 已断开专用以太网 已启用 已连接 专用 Wi-Fi

C:\WINDOWS\system32>netsh interface set interface name="Ethernet" admin=enable or disable

w10 输出这个..

于 2016-06-20T19:58:21.697 回答
1

好吧,看起来您需要从表中删除配置文件。IE

netsh LAN>删除“LAN连接配置文件”

在此之前,您应该保存 LAN 的配置信息,以防您想将其添加回来,它将保存为 XML 文件,然后将其添加回来就可以了

netsh LAN>ADD file-name="profile1.XML" interface="Local Area Connection"

另请查看http://www.computerhope.com/netsh.htm了解有关 netsh 命令的更多详细信息

希望这可以帮助

于 2013-11-18T14:08:54.847 回答
0
  1. 以管理员身份启动命令提示符。

  2. 要显示包含“接口名称”、“状态”等的列表,请键入以下内容:

    netsh 界面 显示界面

它会回响应该像这样的东西。

> netsh interface show interface

Admin State    State          Type             Interface Name
-------------------------------------------------------------------------
Enabled        Connected      Dedicated        Local Area Connection
Disabled       Disconnected   Dedicated        Local Area Connection 4
  1. 现在,从您的列表中选择一个“接口名称”。 例如,如您所见,我的是“本地连接”

启用选定的连接类型,请执行以下操作:

“%InterfaceName%”在哪里放置您的接口名称。注意:如果包含空格,请用双引号 ["] 关闭“接口名称”,例如我的:“本地连接”。

netsh interface set interface "%InterfaceName%" ENABLE

或者,如果不适合您,请尝试下一个:

netsh interface set interface name="%InterfaceName%" admin=ENABLED

禁用选定的连接类型,请执行以下操作:

 netsh interface set interface "%InterfaceName%" DISABLE

或者,如果不适合您,请尝试下一个:

netsh interface set interface name="%InterfaceName%" admin=DISABLED

提示:您只需双击即可创建“Restart Connection.cmd”或“Restart Connection.bat”来完成这项工作。;) 这可能是这样的:

@echo off
mode con: cols=80 lines=27
title Connection Restart
color 1f
cls
echo  This program restarts Internet Connection adapter.
echo.
echo  List of network adapters (Internet adapters)
netsh interface show interface
echo ==========================================================================

:: Setting Interface Name
set InterfaceName=Local Area Connection

:Disadling adapter
echo. & echo
echo  RESTARTING "%InterfaceName%" adapter. WAIT...
netsh interface set interface "%InterfaceName%" disable
echo "%InterfaceName%" adapter disabled. Wait...
echo. & echo.==========
timeout /t 5 >nul

:Enabling adapter
netsh interface set interface "%InterfaceName%" enable
echo "%InterfaceName%" adapter Enabled. Wait...
echo. & echo.==========
echo  Procedure completed successfully

timeout /t 6 >nul
EXIT

请注意,您唯一需要在此批次中替换以使其适合您的是第 13 行中“接口名称”的(确切)名称。

例如,粗体的名称: set InterfaceName= Local Area Connection

此行(第 13 行)使此变量为“%InterfaceName%”,因此您无需更改任何其他内容即可工作。但如果你愿意,你会尝试。

享受

于 2021-05-18T18:19:11.040 回答