As via the command line (CMD) change the IP address from the active Internet connection?

Only realized that it is necessary to dig in the direction of the netsh utility, or rather netsh set address. The problem is that you need to explicitly specify the network connection name for which changes IP address, and needs to read the script itself, automatically. How to do it then? I think that somewhere in the registry should be considered a key value that stores the name of the current network connection.
July 12th 19 at 17:04
2 answers
July 12th 19 at 17:06
netsh interface ip set address name=”Local Area Connection” static 192.168.0.1 255.255.255.0 192.168.0.254

Find out the current connection you can use ipconfig
Or you have something else to do want?
I need automation. Need to bat in the file name could substitute for the name of the current network to which you are currently connected to the computer. So I write something, like a universal replace the settings of an IPv4 connection for an active connection. - ashlynn.Bogan commented on July 12th 19 at 17:09
Oh you're a hedgehog. And these people we will say, that Windows was all so simple.
Is that the ip address add 192.168.0.77/24 dev eth0 is difficult, and netsh interface ip set address name=”Local Area Connection” static 192.168.0.254 255.255.255.0 192.168.0.77 it's just.

Damn, now use easy to unsee, but it's a night dream, so mattress not leg it. - Billy_Davis commented on July 12th 19 at 17:12
July 12th 19 at 17:08
set "wmic=wmic path Win32 networkadapter where NetConnectionStatus="2" get netconnectionid key /value"
for /f "tokens=2 delims==" %%a in (' "%wmic%" ') do set IfName=%%a
netsh int ip set address name="%IfName%" static 192.168.0.1 255.255.255.0 192.168.0.254

Find more questions by tags Command lineComputer networksSystem administrationcmd/batIP