批处理修改IP
上次一个网友要我做的一个IP转换的批处理,贴出来给大家使用.可以在2个IP之前相互转换,不必再去修改本地连接了,你要做的只是输入1或者2。请按自己的须求做相应的修改,源码如下
@echo off
title IP转换工具 Powered By Djhui http://www.djhui.cn
MODE con: COLS=40 lines=10
color 0a
:main
cls
echo 要把IP转换为192.168.2.220 请按1
set /p choice= 要把IP转换为192.168.2.240 请按2
if "%choice%"=="1" goto ip1
if "%choice%"=="2" goto ip2
goto main
:ip1
echo 正在设置IP及子网掩码
netsh interface ip set address name="本地连接" source=static addr=192.168.2.220 mask=255.255.255.0
@rem 以上这句是设置IP为192.168.2.220 子网掩码为255.255.255.0
echo 正在设置网关地址
netsh interface ip set address name="本地连接" gateway=192.168.2.1 gwmetric=0
@rem 以上这句为设置网关为192.168.2.1
echo 正在设置DNS服务器
netsh interface ip set dns name="本地连接" source=static addr=192.168.2.1 register=PRIMARY
@rem 以上这句为设置DNS为192.168.2.1
echo 设置完成
echo Powered By Djhui
echo http://www.djhui.cn&pause
goto main
:ip2
echo 正在设置IP及子网掩 码
netsh interface ip set address name="本地连接" source=static addr=192.168.2.240 mask=255.255.255.0
@rem 以上这句是设置IP为192.168.2.240 子网掩码为255.255.255.0
echo 正在设置网关地址
netsh interface ip set address name="本地连接" gateway=192.168.2.1 gwmetric=0
@rem 以上这句为设置网网为192.168.2.1
echo 正在设置DNS服务器
netsh interface ip set dns name="本地连接" source=static addr=192.168.2.1 register=PRIMARY
@rem 以上这句为设置DNS为192.168.2.1
echo 设置完成
echo Powered By Djhui
echo http://www.djhui.cn&pause
goto main
2008-6-14 AM 12:25:37 回复该留言
写的不错。