Get Network Interface Names and Set All to DHCP Batch Script

ぐ巨炮叔叔 提交于 2019-12-10 11:48:29

问题


I am trying to make a batch that will get all of the Network Interface names (ex. 'Local Area Connection', 'Local Area Connection 2') and set them to DHCP.

This is what I have so far:

set netsh=wmic nic where "netconnectionid like '%%'" get netconnectionid

for %%i in ("%netsh% | FIND /V 'Net'") do (netsh interface ip set address "%%i" dhcp)

My output is:

The filename, directory name, or volume label syntax is incorrect.

Can anyone assist me in fixing this script, or proposing a better way to go about this please?


回答1:


Will this do what you need?

WMIC NICConfig Where "IPEnabled='True' And DHCPEnabled='False'" Call EnableDHCP


来源:https://stackoverflow.com/questions/46391575/get-network-interface-names-and-set-all-to-dhcp-batch-script

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