4

我正在尝试制作一个可以更改 pc/笔记本电脑 IP 地址和子网掩码的程序。我试图做的输入与windows(ip/subnet,dns/alternate dns)上IPv4属性的接口相似。

我现在能想到的那些是使用 netsh 命令来更改 Windows ip。我想要做的是在 Windows 上设置/获取以太网设置

提前致谢

4

1 回答 1

6

您可以在 JAVA 中更改注册表,这应该可以解决问题。这些应该有助于:

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

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

其他方法是从 JAVA 调用 netsh 命令:

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);
于 2013-10-15T08:19:35.273 回答