通过java程序改变网络设置

时间:2009-10-25 20:51:10

标签: java networking lan

我想编写一个程序来重置用户的局域网/(TCP / IP)属性。

这是我手动做的(我想自动编程):

1) START -> Run -> cmd (get command prompt)
2) ipconfig /release
3) START -> Connect to -> Show all connections
4) Right-click "Local Area Network" and click "Properties"
5) Highlight "Internet Protocol (TCP/IP) and click "Properties"
6) Check box "Use the following IP Address"
7) Enter "111.111.111.111" for IP address
8) Enter "255.0.0.0" for Subnet mask
9) Click OK, and Close.
10) Wait 20 seconds
11) START -> Connect to -> Show all connections
12) Check box for "Obtain IP address automatically"
13) Click OK, and close.
14) Wait 20 seconds.

我想通过我的java程序执行以上14个步骤。我该怎么办?是否有任何api允许我设置上面的paramarers。必须保存chnages,即使我重新启动我的电脑也应该保留。我希望pragram只运行一次而不是在我启动电脑的时候。

2 个答案:

答案 0 :(得分:1)

您似乎正在尝试使用DHCP续订IP地址。

不要编写Java程序,而是编写以下批处理文件:

ipconfig /renew

答案 1 :(得分:0)

仅通过Runtime.exec(如SLaks所述)或使用JNI。没有原生JAVA  据我所知,能够处理这个问题的图书馆。