问题
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