Place where I work, our desktops are locked down so regular users have no access to the network settings. And since I am always logged in as a regular user and only use my admin account via RunAs (because it’s best practice not to be logged in with your admin account) I don’t have access to the network settings window either. Of course I could logout-login, but who does that!?
Enter netsh
(or PowerShell if you are on Windows 8, but I am on Windows 7 at work).
To show your currently assigned IPv4 addresses and interfaces:
1 |
netsh interface ipv4 show address |
To set a Static IPv4 address for the “Local Area Connection” interface:
1 |
netsh interface ipv4 set address "Local Area Connection" static 192.168.0.10 255.255.255.0 192.168.0.1 |
And to set a DHCP IPv4 address for the “Local Area Connection” interface:
1 |
netsh interface ipv4 set address "Local Area Connection" dhcp |
Easy peasy! (sort of)
A cool thing about netsh
is that it’s an interactive shell so you can type netsh
at the command prompt to enter the shell and then navigate around to get a list of commands and slowly figure your way out.