How can I programmatically change a static IP address?

I have a box running windows which I want to assign a static IP to but give remote access to change that IP (without giving complete access to the windows instllation). I want to run a little app or command or something similar to connect to that machine and tell it to try and change it's IP address to a new value. If there are any problems with that, it should change itself back again after a timeout.

Is there any free software out there which will do the whole lot? ..or are there command line utilities I could wrap in a bit of Python? ...or any other options?


Solution 1:

I think the netsh utility may be what you need for this. Of course you can call that from within your own program/script. It's been quite a while since I used it so can't really remember the specifics.

Solution 2:

John's got it, but in addition, I found some good examples of what you can do with it.

netsh interface ip set address name="Local Area Connection" static 192.168.1.191 255.255.255.0

...will set the machine's IP to 192.168.1.191 and it's subnet mask to 255.255.255.0