软件工程

本类阅读TOP10

·PHP4 + MYSQL + APACHE 在 WIN 系统下的安装、配置
·Linux 入门常用命令(1)
·Linux 入门常用命令(2)
·使用 DCPROMO/FORCEREMOVAL 命令强制将 Active Directory 域控制器降级
·DirectShow学习(八): CBaseRender类及相应Pin类的源代码分析
·基于ICE方式SIP信令穿透Symmetric NAT技术研究
·Windows 2003网络负载均衡的实现
·一网打尽Win十四种系统故障解决方法
·数百种 Windows 软件的免费替代品列表
·收藏---行百里半九十

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
用批处理轻松实现IP配置的修改

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

在有了本本以后移动性的增加不光给自己带来了方便,也有不如意之处,如换来换去的IP。网上倒是有相当多的软件可以设置,但是装那些软件总感觉不爽,于是自己研究了如何在windows下用批处理实现IP配置的修改。我们先看一下netsh命令的用法:
netsh命令:
Usage: netsh [-a AliasFile] [-c Context] [-r RemoteMachine] 
             [Command │ -f ScriptFile]

The following commands are available:

Commands in this context:
?              - Displays a list of commands.
add            - Adds a configuration entry to a list of entries.
bridge         - Changes to the `netsh bridge' context.
delete         - Deletes a configuration entry from a list of entries.
diag           - Changes to the `netsh diag' context.
dump           - Displays a configuration script.
exec           - Runs a script file.
firewall       - Changes to the `netsh firewall' context.
help           - Displays a list of commands.
interface      - Changes to the `netsh interface' context.
ras            - Changes to the `netsh ras' context.
routing        - Changes to the `netsh routing' context.
set            - Updates configuration settings.
show           - Displays information.

The following sub-contexts are available:
 bridge diag firewall interface ras routing
看明白用法以后,在"运行"里输入"cmd",进入命令行模式,然后输入:
netsh interface ip dump >C:\1.txt
命令运行完成后到C盘下查看1.txt文件,我的配置如下:
# ----------------------------------
# Interface IP Configuration        
# ----------------------------------
pushd interface ip


# Interface IP Configuration for "Local Area Connection"

set address name="Local Area Connection" source=static addr=***.***.***.*** mask=***.***.***.***set address name="Local Area Connection" gateway=***.***.***.*** gwmetric=0
set dns name="Local Area Connection" source=static addr=***.***.***.*** register=PRIMARY
set wins name="Local Area Connection" source=static addr=none


popd
# End of interface IP configuration
将以上文件中的除set ...那四行保留,去年其他所有行。然后将剩余的每一行前加上netsh interface ip,这样就形成如下文件:

netsh interface ip set address name="Local Area Connection" source=static addr=192.168.1.2 mask=255.255.255.0
netsh interface ip set address name="Local Area Connection" gateway=192.168.1.1 gwmetric=0
netsh interface ip set dns name="Local Area Connection" source=static addr=192.168.1.1 register=PRIMARY
netsh interface ip set wins name="Local Area Connection" source=static addr=none。

(注意:此文件是在windowsXP 英文版下生成,在中文系统下请做相应调整。)
将以上文件重命名为XXX.bat文件,copy一份,将另一个IP配置表根据上文内容进行相应修改,保存为xxx2.bat,这个当你想使用配置1的时候就双击xxx.bat,使用2的时候双击xxx2.bat等命令行界面闪过之后你的新IP配置就可以使用了。
(在windows98下没有做过测试。)




相关文章

相关软件