Friday, February 26, 2016

Remotely change the IP address of a Windows PC


Command line to spawn a cmd.exe process on remote computer :
psexec.exe \\computername -u computername\administrator cmd.exe
It should then ask you for administrator password, and then spawn process.  From there you can start playing with netsh as like you are on the remote computer, here a main command lines for netsh control :
  • Display IP configuration : netsh interface ip show config
  • Change default gateway on Windows XP : netsh interface ip set address “Local Area Connection” gateway=192.168.0.1 gw=0
  • Change ip, netmask and default gateway on Windows Vista/7/8 : netsh interface ip set address “Local Area Connection” static 192.168.0.10 255.255.255.0 192.168.0.1
  • Change main DNS server : netsh interface ip set dns “Local Area Connection” static 192.168.0.1
  • Add a second DNS server : netsh interface ip add dns “Local Area Connection” static 192.168.0.2
 Note : Remember to input correct “Local Area Connection” on previous commands.

Play with netsh -r

You can remotely change IP config on an domain administrator account using the following switch of netsh command : -r
For example : netsh -r REMOTE_MACHINE_NAME interface ip show config