1

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?

curious
  • 1,504
  • 5
  • 18
  • 32
C. Gordon
  • 11
  • 3

1 Answers1

2

Will this do what you need?

WMIC NICConfig Where "IPEnabled='True' And DHCPEnabled='False'" Call EnableDHCP
Compo
  • 36,585
  • 5
  • 27
  • 39