来源:自学PHP网 时间:2015-04-17 17:12 作者: 阅读:次
[导读] Windows下通过脚本快速修改IP地址案例[plain]@echo off :main cls color 02 echo.--------------------------------------------- echo. 欢迎使用PrudentWoo制作的IP地址切换脚本 echo. 脚本式针对Win......
Windows下通过脚本快速修改IP地址案例
[plain]
@echo off
:main
cls
color 02
echo.---------------------------------------------
echo. 欢迎使用PrudentWoo制作的IP地址切换脚本
echo. 脚本式针对Windows平台进行脚本切换
echo. http://www.prudentwoo.com PrudentWoo?
echo.--------------------------------------
echo. 1. Wlan(无线网卡预置IP地址设定)
echo. 2. Ethernet(以太网网卡预置IP地址设定)
echo. 3. IP地址自定义
echo. 4. 清理DNS缓存
echo. 5. 开启或关闭WIFI热点
echo. 6. IP地址信息
echo. 7. Exit
echo.--------------------------------------
set /p choice=请输入执行项目序号:
echo.
if %choice%==1 goto Wlan
if %choice%==2 goto Ethernet
if %choice%==3 goto IP-Selfset
if %choice%==4 goto Clear DNS
if %choice%==5 goto WIFI
if %choice%==6 goto IP_Info
if %choice%==7
cls
goto end
@rem 以下是无线网卡预置IP地址设定批处理
:Wlan
cls
color 03
echo.您正在执行Wi-Fi IP地址设置操作!
echo.------------------------------
echo 1. 设置为Wi-Fi DHCP
echo 2. 设置Wi-Fi静态公网IP
echo 3. 返回
echo.-----------------------------
set /p choice=请选择执行项目序号:
if %choice%==1 goto 1
if %choice%==2 goto 2
if %choice%==3 goto 3
:1
echo.正在进行DHCP设置,请稍等... echo.IP地址正在从DHCP自动获取...
netsh interface ip set address "Wi-Fi"dhcp
echo.DNS地址正在从DHCP自动获取...
netsh interface ip set dns "以太网"dhcp
echo.全部设置完成!---
@Pause
goto end
:2
echo.正在进行Wi-Fi公网IP设置,请稍等...
echo.ip地址=192.168.1.123
echo.子网掩码=255.255.255.0
echo.默认网关=192.168.1.1
echo.首选DNS=10.252.8.5
echo.备选DNS=10.252.8.4
net interface ip set address name="Wi-Fi" source=static
addr=192.168.1.123 mask=255.255.255.0 >null
net interface ip set address name="Wi-Fi" gateway=192.168.1.1
gwmetric=1 >null
net interface ip set dns name="Wi-Fi" source=static addr=10.252.8.5
net interface ip add dns name="Wi-Fi" 10.252.8.4 index=2
echo全部设置完成!
echo请按任意键退出...
@Pause
goto end
:3
Goto main
@rem 以下是以太网网卡预置IP地址设定批处理
:Ethernet
cls
color 2f
echo.您正在执行Ethernet IP地址设置操作!
echo.-----------------------------------
echo 1. 设置Ethernet为DHCP方式
echo 2. 设置Ethernet静态公网IP1(办公网络)
echo 3. 设置Ethernet静态公网IP2(宿舍网络)
echo 4. 返回
echo.-----------------------------------
set /p choice=请选择执行项目序号:
if %choice%==1 goto 1
if %choice%==2 goto 2
if %choice%==3 goto 3 if %choice%==4 goto 4
:1
cls
color 26
echo.正在进行DHCP设置,请稍等...
echo.IP地址正在从DHCP自动获取...
netsh interface ip set address name = "以太网" source=dhcp
echo.DNS地址正在从DHCP自动获取...
netsh interface ip set dns "以太网" source=dhcp
echo.全部设置完成!
@Pause
goto enthernet
:2
cls
color 35
echo 正在进行Ethernet公网静态IP1(办公网络)设置,请稍等...
echo.
echo.设置参数为:
echo.---------------------------
echo.ip地址=198.9.2.123
echo.子网掩码=255.255.255.0
echo.默认网关=198.9.2.1
echo.首选DNS=202.112.20.131
echo.---------------------------
echo.正在设置上述IP参数...
ipconfig /release
netsh interface ip add address name="以太网" addr=198.9.2.123 mask=255.255.255.0 gateway=198.9.2.1
netsh interface ip add address name="以太网" addr=10.2.2.234 mask=255.255.255.0 gateway=10.2.2.254
netsh interface ip add address name="以太网" addr=10.0.0.10 mask=255.0.0.0
netsh interface ip add address name="以太网" addr=192.168.133.20 mask=255.255.255.0
netsh interface ip add address name="以太网" addr=192.168.54.345 mask=255.255.255.0
netsh interface ip add address name="以太网" addr=192.168.7.1 mask=255.255.255.0
netsh interface ip add dns name = "以太网" addr = 202.106.0.20
netsh interface ip add dns name = "以太网" addr = 211.147.6.3
netsh interface ip add dns name = "以太网" addr = 202.106.0.21
netsh interface ip add dns name = "以太网" addr = 202.105.12.226
netsh interface ip add dns name = "以太网" addr = 61.144.56.100
netsh interface ip add dns name = "以太网" addr = 202.96.128.68
netsh interface ip add dns name = "以太网" addr = 202.96.128.86
echo.全部设置完成!
@Pause
goto ethernet
:3
echo 正在进行Ethernet公网静态IP2设置(宿舍网络),请稍等...
echo.
echo.设置参数为:
echo.---------------------------
echo.ip地址= 192.168.1.33
echo.子网掩码=255.255.255.0
echo.默认网关=192.168.1.33
echo.首选DNS=61.144.56.100
echo.---------------------------
ipconfig /release
netsh interface ip add address name="以太网" addr=192.168.1.33 mask=255.255.255.0 gateway=192.168.1.1
netsh interface ip add dns name = "以太网" addr = 202.106.0.20
netsh interface ip add dns name = "以太网" addr = 211.147.6.3
netsh interface ip add dns name = "以太网" addr = 202.106.0.21
netsh interface ip add dns name = "以太网" addr = 202.105.12.226
netsh interface ip add dns name = "以太网" addr = 61.144.56.100
netsh interface ip add dns name = "以太网" addr = 202.96.128.68
netsh interface ip add dns name = "以太网" addr = 202.96.128.86
echo.全部设置完成!
@Pause
goto enthernet
:4
goto main
@rem 以下是以IP地址自定义批处理
:ip-selfset
cls
echo.您正在执行Ethernet IP地址自定义设置操作!
:ip1
cls
color 13
echo.IP自定义设置开始....
echo.
echo 开始设置IP及子网掩码
set /p saddr=请输入静态地址:
if /i "%saddr%"=="" goto ip1
set /p mask=请输入子网掩码:
if /i "%mask%"=="" goto ip1
set /p gateway=请输入默认网关:
if /i "%gateway%"==""goto ip1
goto IP_judge
:IP_judge
cls
echo.您输入的IP地址参数如下:
echo.————————————————————
echo. IP地址:%saddr%
echo. 子网掩码:%mask%
echo. 默认网关:%gateway%
echo.————————————————————
echo.
echo.以上参数正确请按 Y 继续,错误请按N返回重设!
echo.
set /p choice= 您的选择:
if "%choice%"=="N" goto ip1
if "%choice%"=="n" goto ip1
if "%choice%"=="Y" goto ipaddr
if "%choice%"=="y" goto ipaddr goto IP_judge
echo.
:ipaddr
cmd /c netsh interface ip set address name="Local Area connection" source=static addr=%saddr%
mask=%mask% gateway=%gateway% gwmetric=1 >nul
goto ipdns
:ipdns
cls
echo 开始设置DNS服务器
set /p dnsaddr=请输入DNS服务器:
if /i "%dnsaddr%"=="" goto :ipdns
@rem 以下语句设置DNS
cmd /c netsh interface ip set dns name="Local Area connection" source=static addr=%dnsaddr%
register=PRIMARY >nul
echo.开始设置DNS备用服务器
set /p dnsaddr2=请输入备用DNS服务器:
if /i "%dnsaddr2%"=="" goto :ipdns
goto DNS_judge
:DNS_judge
cls
echo.
echo.——————————————————————————
echo.
echo. DNS首选服务器:%dnsaddr%
echo.
echo. DNS备用服务器: %dnsaddr2%
echo.
echo.——————————————————————————
echo.以上DNS参数正确请按Y继续,否则请按N返回重设!
echo.
set /p choice= 您的选择:
if "%choice%"=="N" goto ipdns
if "%choice%"=="n" goto ipdns
if "%choice%"=="Y" goto ipdns2
if "%choice%"=="y" goto ipdns2
goto DNS_judge
:ipdns2
cmd /c netsh interface ip add dns name="Local Area Connection" addr=%dnsaddr2%
index=2 >nul
echo.设置完成 @pause
goto main
if errorlevel 2 goto main
if errorlevel 1 goto end
:Clear DNS
cls
cmd /c ipconfig/flushdns
echo.DNS缓存清理完成!
@pause
goto main
:WIFI
cls
echo.您正在执行WIFI热点设置操作!
echo.-----------------------------------
echo 1. 开启WIFI Hoc
echo 2. 关闭WIFI Hoc
echo.-----------------------------------
set /p choice= 输入您的选择序号:
if "%choice%"=="1" goto start
if "%choice%"=="2" goto stop
:start
cmd /c netsh wlan start hostednetwork
@Pause
goto main
:stop
@Pause
goto main
cmd /c netsh wlan stop hostednetwork
:IP_Info
cls
color 5f
echo.以下是您的IP地址信息:
cmd /c ipconfig /all
@pause
goto main
|
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com