4

I'm trying to make a program that can change pc/laptop ip address & subnet mask. the input I'm trying to make is similar with the interface on IPv4 properties on windows(ip/subnet, dns/alternate dns).

the ones that I can think of right now is using a netsh command to change the windows ip. what i want to do is to set/get the ethernet setting on windows

thanks in advance

Ferdie Vianto
  • 43
  • 1
  • 1
  • 4

1 Answers1

6

You can change the registry in JAVA, wich should do the trick. These should help:

http://www.windowsreference.com/networking/dhcp-static-ip-settings-in-windows-registry/

http://www.windowsreference.com/networking/dhcp-static-ip-settings-in-windows-registry/

Other method is to call the netsh command from JAVA:

String str1="192.168.0.201";
String str2="255.255.255.0";
String[] command1 = { "netsh", "interface", "ip", "set", "address",
"name=", "Local Area Connection" ,"source=static", "addr=",str1,
"mask=", str2};
Process pp = java.lang.Runtime.getRuntime().exec(command1);
Ezzored
  • 905
  • 4
  • 10