Enable/disable network connection from command line

大城市里の小女人 提交于 2019-12-31 11:45:50

问题


I know that there exists ton of results in Google for this: results, but I didn't make it in my Windows XP machine. I want to disable LAN connection from command line.

>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.

回答1:


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"



回答2:


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.)




回答3:


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




回答4:


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..



来源:https://stackoverflow.com/questions/19831023/enable-disable-network-connection-from-command-line

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