Is there a way to change the Subnet Mask using NETSH without changing the IP Address?
Our company is planning on switching to a new subnet in the near future to make more room on the network. 开发者_如何学JAVAI thought that the transition might go smoother if we had a batch file that everyone could run to change the subnet for them.
My code thus far looks like this:
set maskvar=255.255.255.0
ECHO Setting IP Address and Subnet Mask
netsh interface ip set address local static mask=%maskvar%
This doesn't work because it wants a value for the address as well, which would look something like this.
netsh interface ip set address local static addr=%addrvar% mask=%maskvar%
I would like to keep the address that is already on the machine. Can I pull it from an already existing variable? Is there a better way to do this?
Any useful input would be greatly appreciated.
Why not pull the ip address from ipconfig, set it as a variable and then assign it in netsh?
精彩评论