windows 7 ip设置批处理

 @echo off
rem //设置变量
set Nic1="本地连接"
set Nic2="无线网络连接"
rem //可以根据你的需要更改,
set Addr1=202.204.74.250
set Addr2=192.168.1.15
set Mask=255.255.255.0
set Gway1=202.204.74.254
set Gway2=192.168.1.1
set DnsN1=202.106.196.115
set DnsN2=202.106.0.20
set DnsE1=202.204.65.5
set DnsE2=202.204.65.6
rem //以上依次为IP地址、子网掩码、网关、首选DNS、备用DNS
:DIE0
echo 1 设置为无线网络
echo 2 设置为有线网络
echo 3 退出
echo ---请选择项目后回车
set /p answer=
if %answer%==1 goto DIE1
if %answer%==2 goto DIE2
if %answer%==3 goto 3
:DIE1
echo 1 设置为NCEPU静态IP
echo 2 设置为家用TP静态IP
echo 3 设置为动态IP
echo 4 返回
echo ---请选择项目后回车
set /p answer=
if %answer%==1 goto W1
if %answer%==2 goto W2
if %answer%==3 goto W3
if %answer%==4 goto 2
:DIE2
echo 1 设置为办公室IP
echo 2 设置为宿舍区IP
echo 3 设置家用静态IP
echo 4 返回
echo ---请选择项目后回车
set /p answer=
if %answer%==1 goto E1
if %answer%==2 goto E2
if %answer%==3 goto E3
if %answer%==4 goto 2
:W1
echo 正在进行NCEPU静态IP设置,请稍等...
rem //可以根据你的需要更改
echo. I P 地址 = %addr1%
echo. 子网掩码 = %Mask%
netsh interface ipv4 set address name=%Nic2% source=static addr=%addr1% mask=%Mask% gateway=%Gway1% gwmetric=0 >nul
echo. 首选 DNS = %DnsN1%
netsh interface ipv4 set dns name=%Nic2% source=static addr=%DnsN1% register=PRIMARY >nul
echo. 备用 DNS = %DnsN2%
netsh interface ipv4 add dns name=%Nic2% addr=%DnsN2% index=2 >nul
echo ----
echo 全部设置完成!
ipconfig /all
pause
goto DIE0
:W2
echo 正在进行家用TP静态IP设置,请稍等...
rem //可以根据你的需要更改
echo. I P 地址 = %addr2%
echo. 子网掩码 = %Mask%
netsh interface ipv4 set address name=%Nic2% source=static addr=%addr2% mask=%Mask% gateway=%Gway2% gwmetric=0 >nul
echo. 首选 DNS = %DnsN1%
netsh interface ipv4 set dns name=%Nic2% source=static addr=%DnsN1% register=PRIMARY >nul
echo. 备用 DNS = %DnsN2%
netsh interface ipv4 add dns name=%Nic2% addr=%DnsN2% index=2 >nul
echo ----
echo 全部设置完成!
ipconfig /all
pause
goto DIE0
:W3
echo 正在进行动态IP设置,请稍等...
echo. IP 地址正在从DHCP自动获取...
netsh interface ip set address "无线网络连接" dhcp
echo. 首选 DNS = %DnsN1%
netsh interface ipv4 set dns name=%Nic2% source=static addr=%DnsN1% register=PRIMARY >nul
echo. 备用 DNS = %DnsN2%
netsh interface ipv4 add dns name=%Nic2% addr=%DnsN2% index=2 >nul
echo ----
echo 全部设置完成!
ipconfig /all
pause
goto DIE0
:E1
echo 正在进行办公室静态IP设置,请稍等...
rem //可以根据你的需要更改
echo. I P 地址 = %addr1%
echo. 子网掩码 = %Mask%
netsh interface ipv4 set address name=%Nic1% source=static addr=%addr1% mask=%Mask% gateway=%Gway1% gwmetric=0 >nul
echo. 首选 DNS = %DnsN1%
netsh interface ipv4 set dns name=%Nic1% source=static addr=%DnsN1% register=PRIMARY >nul
echo. 备用 DNS = %DnsN2%
netsh interface ipv4 add dns name=%Nic1% addr=%DnsN2% index=2 >nul
echo ----
echo 全部设置完成!
ipconfig /all
pause
goto DIE0
:E2
echo 正在进行宿舍区IP设置,请稍等...
echo. IP 地址正在从DHCP自动获取...
netsh interface ip set address "无线网络连接" dhcp
echo. 首选 DNS = %DnsE1%
netsh interface ipv4 set dns name=%Nic1% source=static addr=%DnsE1% register=PRIMARY >nul
echo. 备用 DNS = %DnsE2%
netsh interface ipv4 add dns name=%Nic1% addr=%DnsE2% index=2 >nul
echo ----
echo 全部设置完成!
ipconfig /all
pause
goto DIE0
:E3
echo 正在进行家用静态IP设置,请稍等...
rem //可以根据你的需要更改
echo. I P 地址 = %addr2%
echo. 子网掩码 = %Mask%
netsh interface ipv4 set address name=%Nic1% source=static addr=%addr2% mask=%Mask% gateway=%Gway2% gwmetric=0 >nul
echo. 首选 DNS = %DnsN1%
netsh interface ipv4 set dns name=%Nic1% source=static addr=%DnsN1% register=PRIMARY >nul
echo. 备用 DNS = %DnsN2%
netsh interface ipv4 add dns name=%Nic1% addr=%DnsN2% index=2 >nul
echo ----
echo 全部设置完成!
ipconfig /all
pause
goto DIE0
:2
echo bye!
goto DIE0
pause
:3
echo bye!
goto end
:END

你可能感兴趣的:(windows,IP地址,本地连接,无线网络)