keywords:windows7 bat自动批处理改变IP地址、DNS和代理设置
改变IP地址设置:
@echo
off
netsh
interface
ipv4
set
address
"
无线网络连接
"
static
192.168
.
100.200
255.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
address name=
"
无线网络连接
"
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
"
/v ProxyEnable /t REG_DWORD /d
1
/
f
reg add
"
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
"
/v ProxyServer /d
"
192.168.100.100:808
"
/
f
reg add
"
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
"
/v ProxyOverride /t REG_SZ /d
""
/
f
echo 正在刷新设置……
ipconfig
/flushdns
关闭IE代理服务器设置:
@echo
off
title 自动清除IE代理
echo 正在清空代理服务器设置……
reg add
"
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
"
/v ProxyEnable /t REG_DWORD /d
0
/
f
reg add
"
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
"
/v ProxyServer /d
""
/
f
reg add
"
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
"
/v ProxyOverride /t REG_SZ /d
0
/
f
echo 代理服务器设置已经清空
echo 正在刷新设置……
ipconfig
/
flushdns
批处理自动选择网络设置全文
注:复制到记事本文件中,别存为,后缀改为”.bat”文件。在win7系统中运行时,会提示,“请求的操作需要提升为<作为管理员运行>”;只需要在此bat文件上右击“以管理员身份运行”即可。
全文如下:
@echo
off
color 1f
title windows
7
多网络环境自动切换管理
echo.
echo
********************************************
echo
*** windows
7
双网络环寺自动切换管理 ***
echo
*** 作者:王明洪 MSN:kswmh@hotmail.com ***
echo
********************************************
echo
*** 设置IP参数,设置IE代理 ***
echo.
echo.
goto
menus
:menus
echo.
echo 请选择:
echo.
echo
1
切换到家庭代理网络
echo.
echo
2
切换到学校自动获取IP地址网络。
echo.
echo
3
放弃设备,退出
echo.
set
/p
select
=
请输入菜单对应数字后回车:
if
/i
"
%select%
"
==
"
1
"
goto
home
if
/i
"
%select%
"
==
"
2
"
goto
school
if
/i
"
%select%
"
==
"
3
"
exit
goto
menus
:home
cls
netsh
interface
ip
reset
"
无线网络连接
"
echo 设置IP...设置网关.....设置子网
netsh
interface
ipv4
set
address
"
无线网络连接
"
static
192.168
.
100.200
255.255
.
255.0
192.168
.
100.1
echo 设置DNS...
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 设置IE代理...
echo 正在设置代理服务器……
reg add
"
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
"
/v ProxyEnable /t REG_DWORD /d
1
/
f
reg add
"
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
"
/v ProxyServer /d
"
192.168.100.100:808
"
/
f
reg add
"
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
"
/v ProxyOverride /t REG_SZ /d
""
/
f
echo 正在刷新设置……
ipconfig
/
flushdns
goto
exit
:school
cls
echo 设置学校网络自动IP地址.
netsh
interface
ipv4
set
address name=
"
无线网络连接
"
source=
dhcp
echo 设置DNS...
netsh
interface
ipv4
set
dns name=
"
无线网络连接
"
source=
dhcp
echo 正在清除代理服务器设置……
echo 正在清空代理服务器设置……
reg add
"
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
"
/v ProxyEnable /t REG_DWORD /d
0
/
f
reg add
"
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
"
/v ProxyServer /d
""
/
f
reg add
"
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
"
/v ProxyOverride /t REG_SZ /d
0
/
f
echo 代理服务器设置已经清空
echo 正在刷新设置……
ipconfig
/
flushdns
goto
exit
:
exit
cls
echo.
cho.
echo.
echo.
echo.
echo
************
恭喜!网络设置以完成。
echo.
echo.
echo.
echo.
echo.
echo.
pause
exit

