Fixed IP and DNS settings
1@echo OFF//do not display subsequent command lines and the current command line2 3Set Netname="The name of the network to be modified"4Set ip=XXX.XXX.XXX.XXX5Set subnetmask=XXX.XXX.XXX.XXX6Set gateway=XXX.XXX.XXX.XXX7Set dns1=XXX.XXX.XXX.XXX8Set dns2=XXX.XXX.XXX.XXX9 Ten@netsh interface IP set address name=%netname% source=static addr=%ip% mask=%subnetmask% gateway=%gateway% gwmetric=1 //Default Gateway Metric One@netsh interface IP set DNS name=%netname% source=static addr=%dns1% Primary//of the main A@netsh interface IP Add DNS name=%netname% addr=%dns2% index=2 //for the specified DNS server address
Auto Get (IP and DNS)
1 @echo OFF 2 3 Set netname=" Ethernet "4 5 @netsh interface IP set address name=%netname% source=DHCP6 @netsh interface ip set DNS name=%netname% SOURCE=DHCP
Windows Batch network adapter settings