用于配置网络设置的批处理文件

时间:2009-10-25 21:02:58

标签: command-line networking batch-file dos

我想写一个具有如下效果的批次。 这是我手动做的(我想自动编程):

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.

2 个答案:

答案 0 :(得分:3)

从这里采取:http://support.microsoft.com/kb/257748

您可以使用 netsh 执行所有网络设置操作。例如:

netsh interface ip set address "Local Area Connection" static 192.168.0.10 255.255.255.0 192.168.0.1 1

答案 1 :(得分:2)

使用基于GUI的宏录制器可能最好地完成这项特殊工作。 否则,使用脚本操作Windows的最强大的工具是WMI和WMI控制台。但这很复杂,请查看维基百科以获取更多信息。这两个链接可能会帮助您入门:

http://quux.wiki.zoho.com/WMIC-Snippets.html

http://codeslammer.wordpress.com/2008/02/21/wmic-a-hidden-gem/