You get a bonus - 1 coin for daily activity. Now you have 1 coin

Changing Network Settings from the Command Line for Windows

Practice



The solution is actually very simple — the NETSH.EXE utility, built into the operating system, will help us.

Static address
netsh interface ip set address name="Подключение по локальной сети" source=static addr=192.168.0.2 mask=255.255.255.0 gateway=192.168.0.1 gwmetric=1
netsh interface ip set dns "Подключение по локальной сети" static 192.168.0.1
netsh interface ip add dns "Подключение по локальной сети" 8.8.8.8

Dynamic address
netsh interface ip set address name="Подключение по локальной сети" source=dhcp
netsh interface ip set dns name="Подключение по локальной сети" source=dhcp

To switch settings on a laptop, you can simply create a couple of bat files and specify your own parameters for each network.
This can also be done with a single file if you set up a user interaction interface, but in some sense that's already overkill.
Attention! Administrator rights are required to change adapter settings! So the bat file must be run as administrator, otherwise the script will display a message about insufficient rights and close the console window, and you'll never find out why it didn't work.

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Operating Systems and System Programming"

Terms: Operating Systems and System Programming