windows7 bat自动批处理改变IP地址、DNS和代理设置

来源:互联网 发布:如何参加淘宝试用 编辑:程序博客网 时间:2024/06/06 04:30

windows7  bat自动批处理改变IP地址、DNS和代理设置

 

改变IP地址设置:

@echo off

netsh interface ipv4 set address "无线网络连接" static 192.168.100.200255.255.255.0 192.168.100.1

netsh interface ipv4 set dns name="无线网络连接" source=static addr=8.8.4.4

netsh interface ipv4 add dns name="无线网络连接" addr=61.177.7.1 index=2

echo------------------------------------------------------------------------------

echo---------------------------------------------------------------------------------

echo -----------------------------

 

改为DHPC(自动获取)设置:

@echo offf

netsh interface ipv4 set addressname="无线网络连接"source=dhcp

netsh interface ipv4 set dns name="无线网络连接" source=dhcp

echo------------------------------

 

开启IE代理服务器设置:

@echo off

title 自动设置代理服务器

echo 正在设置代理服务器……

reg add"HKCU/Software/Microsoft/Windows/CurrentVersion/Internet Settings" /vProxyEnable /t REG_DWORD /d 1 /f

reg add"HKCU/Software/Microsoft/Windows/CurrentVersion/Internet Settings" /vProxyServer /d "192.168.100.100:808" /f

reg add"HKCU/Software/Microsoft/Windows/CurrentVersion/Internet Settings" /vProxyOverride /t REG_SZ /d "" /f

echo 正在刷新设置……

ipconfig /flushdns

 

关闭IE代理服务器设置:

@echo off

title 自动清除IE代理

 

echo 正在清空代理服务器设置……

reg add"HKCU/Software/Microsoft/Windows/CurrentVersion/Internet Settings" /vProxyEnable /t REG_DWORD /d 0 /f

reg add"HKCU/Software/Microsoft/Windows/CurrentVersion/Internet Settings" /vProxyServer /d "" /f

reg add"HKCU/Software/Microsoft/Windows/CurrentVersion/Internet Settings" /vProxyOverride /t REG_SZ /d 0 /f

echo 代理服务器设置已经清空

echo 正在刷新设置……

ipconfig /flushdns

 

批处理自动选择网络设置全文

注:复制到记事本文件中,别存为,后缀改为”.bat”文件。在win7系统中运行时,会提示,“请求的操作需要提升为<作为管理员运行>”;只需要在此bat文件上右击“以管理员身份运行”即可。

全文如下:

@echooff

color 1f

titlewindows 7 多网络环境自动切换管理

echo.

echo  ********************************************

echo  *** windows 7 双网络环寺自动切换管理   ***

echo  *** 作者:王明洪 MSN:kswmh@hotmail.com ***

echo  ********************************************

echo  *** 设置IP参数,设置IE代理 ***

echo.

echo.

gotomenus

:menus

echo.

echo 请选择:

echo.

echo 1切换到家庭代理网络

echo.

echo 2切换到学校自动获取IP地址网络。

echo.

echo 3放弃设备,退出

echo.

set /pselect=请输入菜单对应数字后回车:

if /i"%select%" == "1" goto home

if /i"%select%" == "2" goto school

if /i"%select%" == "3" exit

gotomenus

:home

cls

netshinterface ip reset "无线网络连接"

echo 设置IP...设置网关.....设置子网

netshinterface ipv4 set address "无线网络连接" static 192.168.100.200 255.255.255.0 192.168.100.1

echo 设置DNS...

netshinterface ipv4 set dns name="无线网络连接" source=static addr=8.8.4.4

netshinterface ipv4 add dns name="无线网络连接" addr=61.177.7.1 index=2

echo 设置IE代理...

echo 正在设置代理服务器……

regadd "HKCU/Software/Microsoft/Windows/CurrentVersion/InternetSettings" /v ProxyEnable /t REG_DWORD /d 1 /f

regadd "HKCU/Software/Microsoft/Windows/CurrentVersion/InternetSettings" /v ProxyServer /d "192.168.100.100:808" /f

regadd "HKCU/Software/Microsoft/Windows/CurrentVersion/InternetSettings" /v ProxyOverride /t REG_SZ /d "" /f

echo 正在刷新设置……

ipconfig/flushdns

gotoexit

 

:school

cls

echo 设置学校网络自动IP地址.

netshinterface ipv4 set address name="无线网络连接" source=dhcp

echo 设置DNS...

netshinterface ipv4 set dns name="无线网络连接" source=dhcp

echo 正在清除代理服务器设置……

echo 正在清空代理服务器设置……

regadd "HKCU/Software/Microsoft/Windows/CurrentVersion/InternetSettings" /v ProxyEnable /t REG_DWORD /d 0 /f

regadd "HKCU/Software/Microsoft/Windows/CurrentVersion/InternetSettings" /v ProxyServer /d "" /f

regadd "HKCU/Software/Microsoft/Windows/CurrentVersion/InternetSettings" /v ProxyOverride /t REG_SZ /d 0 /f

echo 代理服务器设置已经清空

echo 正在刷新设置……

ipconfig/flushdns

gotoexit

 

:exit

cls

echo.

cho.

echo.

echo.

echo.

echo************恭喜!网络设置以完成。

echo.

echo.

echo.

echo.

echo.

echo.

pause

exit

原创粉丝点击