Enable/disable network connection from command line

邮差的信 提交于 2019-12-02 23:50:15
Yarish Kumar

For the first two commands, you need elevated/ administrator rights:

Disable the LAN network connection

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

Enable the LAN network connection

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

assumption : your interface was named as "Local Area Connection" else substitute proper name. Use netsh interface show interface to find the name.

List Wifi profiles

C:\> netsh wlan show profiles

Connect to Wifi profile

C:\> netsh wlan connect name="ProfileName"

You have to run it with elevated/ admin privileges.

(On Windows 7, I otherwise get the confusing error message

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

)

(I edited @yarish kumar's answer to reflect this.)

okay it looks like you need to delete the profile from the table. I.E.

netsh LAN>delete "profile of LAN connection"

before this you should save the configuration info of the LAN in case you want to ADD it back it will save as an XML file then to add it back just do

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

also look at http://www.computerhope.com/netsh.htm for more details about netsh commands

Hope this helps

C:\WINDOWS\system32>netsh interface show interface

Admin State State Type Interface Name

Enabled Connected Dedicated Ethernet 2 Enabled Disconnected Dedicated Ethernet Enabled Connected Dedicated Wi-Fi

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

w10 output this..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!