通过java程序改变网络设置
我想编写一个程序来重置用户的局域网/(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 允许我设置上述参数。chnages 必须被保存,即使当我重新启动我的电脑时也应该保留。我希望该程序仅运行一次,而不是每次启动我的电脑时运行。
I want to write a program that will reset a user's Local Area Network / (TCP/IP) Properties.
Here's what I do manually (which I want to program to do automatically):
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.
I want to do above 14 steps via my java program.How do i do it?Are there any api that allows me to set the above paramarers.The chnages must be saved and should remain even when i restart my pc.I want the pragram to run only once and not eveery time when i start my pc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您似乎正在尝试使用 DHCP 更新您的 IP 地址。
不要编写 Java 程序,而是编写以下批处理文件:
You appear to be trying to renew your IP address using DHCP.
Instead of writing a Java program, write the following batch file:
仅通过 Runtime.exec (如 SLAks 中提到的)或使用 JNI。没有原生JAVA
据我所知,该库能够处理这个问题。
Only through Runtime.exec (as SLaks mentioned) or using JNI. There is no native JAVA
library which is capable of handling this issue as far as i know.