通过java程序改变网络设置

发布于 2024-08-08 16:57:57 字数 780 浏览 5 评论 0原文

我想编写一个程序来重置用户的局域网/(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凶凌 2024-08-15 16:57:57

您似乎正在尝试使用 DHCP 更新您的 IP 地址。

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

ipconfig /renew

You appear to be trying to renew your IP address using DHCP.

Instead of writing a Java program, write the following batch file:

ipconfig /renew
泅渡 2024-08-15 16:57:57

仅通过 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文