I would like to change an IP address in a Wireless network connection with a cmd line. I have tried:

Netsh -c "interface ipv4" set address name=”Wireless Network Connection” static 192.168.168.6 255.255.255.0 192.168.168.168

*Note The above cmd belongs all on one line

I'm getting an error saying: the filename directory name or volume label syntax is incorrect

The second question I have is, I would like to know how to set the secondary DNS. I think this cmd is working for the primary DNS:

netsh interface ipv4 set dnsservers "Wireless Network Connection" static 8.8.8.8 primary validate=no

I'm working in Win7 Ultimate 32bit

Your syntax does not appear to be correct. Try:

netsh interface ipv4 set address "Wireless Network Connection" static 192.168.168.6 255.255.255.0 192.168.168.168

and to add secondary DNS:

netsh interface ipv4 add dns "Wireless Network Connection" 8.8.4.4 index=2
  • Thank you answering this. The static IP worked great. The second DNS is giving me an error saying "The parameter is incorrect.". The help for Netsh doesn't have "index" as a option in Win7. – Docfxit Jun 10 '16 at 18:48
  • Index is invalid only in Windows XP. On 7, it's a valid option: " index (from /? help) - Specifies the index (preference) for the specified DNS server address." Looks like the word 'static' is no longer needed in case of secondary+ entries. Try without 'static' and it will work. I've updated the main reply. – Overmind Jun 14 '16 at 5:55
  • Thank you very much for resolving the issue. The cmd line does work great. Silly me the word add really does add the DNS. What I really need is replace the DNS. If there is something in the secondary DNS I would like to remove it and then replace it with a new DNS. – Docfxit Jun 17 '16 at 2:33
  • What I really need is replace the DNS. If there is something in the secondary DNS I would like to remove it and then replace it with a new DNS. – Docfxit Jul 3 '16 at 23:40
  • netsh interface ipv4 delete dns - this can remove it, you can use index, just like for adding. – Overmind Jul 4 '16 at 5:42

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.