联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
@echo off&set connectionname=本地连接&set gw= for /f "skip=2 tokens=1,2 delims==" %%a in ('find /i "%computername%" %~nx0) do ( if not "%%a%%b" == "" ( netsh interface ip set address "%connectionname%" static %%b 255.255.255.0 %gw%) ) goto :eof 以下为配置 computer001=192.168.1.1 ...
@echo off set 接口名称=本地连接 set 子网掩码=255.255.254.0 set DNS1=202.96.128.86 set DNS2=202.96.128.166 set 网关=192.168.0.201 set 本机IP= for /f "usebackq tokens=2 delims==" %%i in (`type 设定文件^|find /i "%computername:~-3%"`) do set 本机IP=%%i if not defined 本机IP goto :没有设定 echo %time% 正在设定 %接口名称% echo 本机IP: %本机IP% echo 子网: %子网掩码% echo 网关: %网关% echo DNS1: %DNS1% ECHO DNS2: %DNS2% netsh interface ip set address "%接口名称%" static %本机IP% %子网掩码% %网关% 1 netsh interface ip set dns "%接口名称%" static %DNS1% netsh interface ip add dns "%接口名称%" %DNS2% GOTO :EOF :没有设定 echo. echo. echo %time% 出错了!在设定文件中找不到本机对应的IP地址. pause CHENALL发表于: 2007-03-28 01:58