Networking 从命令行启用/禁用网络连接

Networking 从命令行启用/禁用网络连接,networking,cmd,windows-xp,Networking,Cmd,Windows Xp,我知道谷歌上有很多这样的搜索结果,但我没有在我的WindowsXP机器上找到。我想从命令行禁用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 nt

我知道谷歌上有很多这样的搜索结果,但我没有在我的WindowsXP机器上找到。我想从命令行禁用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.

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

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

在此之前,您应该保存LAN的配置信息,以防您要将其添加回,它将保存为XML文件,然后再添加回,只需执行以下操作

netsh LAN>ADD file name=“profile1.XML”interface=“局域网连接”

另请参阅以获取有关netsh命令的更多详细信息

希望这有助于

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

禁用LAN网络连接

C:\> netsh interface set interface name="Local Area Connection" admin=disabled
C:\> netsh interface set interface name="Local Area Connection" admin=enabled
启用LAN网络连接

C:\> netsh interface set interface name="Local Area Connection" admin=disabled
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"

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

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

具有此名称的接口未向路由器注册。

)


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

C:\WINDOWS\system32>netsh interface show interface

管理状态状态类型接口名称 已启用连接专用以太网2 启用断开连接的专用以太网 已启用连接的专用Wi-Fi


C:\WINDOWS\system32>netsh interface set interface name=“Ethernet”admin=启用或禁用

w10输出此

  • 以管理员身份启动命令提示符

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

     netsh interface set interface "%InterfaceName%" DISABLE
    
    netsh接口显示接口

  • 它会回应像这样的事情

    > netsh interface show interface
    
    Admin State    State          Type             Interface Name
    -------------------------------------------------------------------------
    Enabled        Connected      Dedicated        Local Area Connection
    Disabled       Disconnected   Dedicated        Local Area Connection 4
    
  • 现在,从列表中选择一个“接口名称”。 例如,如您所见,我的是“本地连接”
  • 要启用所选连接,请执行以下操作:

     netsh interface set interface "%InterfaceName%" DISABLE
    
    “%InterfaceName%”的位置放置您的接口名称小心:如果包含空格,请用双引号[“]关闭“接口名称”,例如:“局域网连接”

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

    netsh interface set interface name="%InterfaceName%" admin=ENABLED
    
    netsh interface set interface name="%InterfaceName%" admin=DISABLED
    
    要禁用所选连接,请执行以下操作:

     netsh interface set interface "%InterfaceName%" DISABLE
    
    或者,如果不适合您,请尝试下一个:

    netsh interface set interface name="%InterfaceName%" admin=ENABLED
    
    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行中您的接口名称的(确切)名称

    例如,以粗体显示的名称: 设置InterfaceName=本地连接

    这一行(第13行)使用变量“%InterfaceName%”,所以您无需更改任何其他内容即可工作。但如果愿意,您可以进行实验


    享受

    首先让我问一下你为什么要这样做?其次,如果你想禁用LAN,为什么不在控制面板中设置它,因为两个LAN不能一起工作。因此,如果两个LAN不能一起工作,我需要设置一个。我不想手动禁用它,我需要使用bat文件禁用自动启用。好的,我知道你要去哪里了,让我看一些东西我告诉你了。我也有同样的问题。你找到解决办法了吗?@Arya,看看我的答案,我希望它有帮助。当在没有提升/admin权限的情况下运行时,第一个命令失败,声称“具有此名称的接口未在路由器上注册”。有没有办法在没有管理员权限的情况下实现这一点?