Changing Network Adapter Settings to DHCP

I am trying to write some short scripts with netsh. One for changing the adapter to static addressing, and the other for replacing the same adapter with DHCP.

I can get a set of adapters with all the correct static address settings using

netsh interface ip set address "Local Area Connection" static 10.61.1.253 255.255.255.0 10.61.1.1 1 

It works great. When I run the following command (a script) to switch to DHCP, I get an error.

 netsh interface ip set address "Local Area Connection" dhcp 

DHCP is already enabled on this interface.

This is on a Windows 7 computer.

Any idea what the problem is?

+4
source share
2 answers

Did I need some time? on the team to figure it out, since I had the same problem, but here is the syntax that worked for me in Windows 7: netsh interface ip set address name = "Local Area Connection" source = DHCP

+2
source

I had a similar problem with Windows 7. I found that if the link does not work on the interface that you are trying to change, you get the message "DHCP is already enabled on this interface." If you connect the cable (set the link), the same command works fine.

+1
source

Source: https://habr.com/ru/post/1346489/


All Articles