日期:2014-05-17 浏览次数:21075 次
@echo off set /P var="请选择您的位置:[1]固定IP,[2]自动获取,[3]取消:" echo. echo. echo 正在设置IP、网关、DNS... echo. if %var%==1 goto config if %var%==2 goto net2 if %var%==3 goto end :config set /P IP="设置固定IP地址:" set /P Gateway="设置网关:" #set /P DNS1="设置首选DNS:" #set /P DNS2="设置备用DNS:" goto net1 :net1 echo ***************************************************** echo IP地址 :%IP% echo 子网掩码:255.255.255.0 echo 网关 :%Gateway% echo ***************************************************** netsh interface ip set address name="Local Area Connection" source=static addr=%IP% mask=255.255.255.0 >nul netsh interface ip set address name="Local Area Connection" gateway=%Gateway% gwmetric=0 >nul #netsh interface ip set dns name="Local Area Connection" source=static addr=%DNS1% register=PRIMARY >nul #netsh interface ip add dns name="Local Area Connection" addr=%DNS2% >nul goto end :net2 netsh interface ip set address name="Local Area Connection" source=dhcp >nul # netsh interface ip set dns name="Local Area Connection" source=dhcp >nul goto end :end echo 设置完毕。 echo. exit