批处理、VBS实现自动设置IP、默认网关、DNS、WINS、IE代理-以“大连”“沈阳”为例一、IE代理.bat@echoofftitle自动设置代理服务器echo自动设置代理服务器remecho正在清空代理服务器设置……remregaddHKCU\Software\Microsoft\Windows\CurrentVersion\InternetSettings/vProxyEnable/tREG_DWORD/d0/fremregaddHKCU\Software\Microsoft\Windows\CurrentVersion\InternetSettings/vProxyServer/d/fremregaddHKCU\Software\Microsoft\Windows\CurrentVersion\InternetSettings/vProxyOverride/tREG_SZ/d0/fremecho代理服务器设置已经清空echo正在设置代理服务器……regaddHKCU\Software\Microsoft\Windows\CurrentVersion\InternetSettings/vProxyEnable/tREG_DWORD/d1/fregaddHKCU\Software\Microsoft\Windows\CurrentVersion\InternetSettings/vProxyServer/d10.15.0.2:3128/fregaddHKCU\Software\Microsoft\Windows\CurrentVersion\InternetSettings/vProxyOverride/tREG_SZ/d10.*.*.*;192.168.*.*;local/f或者用下面的方法:clscolor1f@echo清空代理设置@echoWindowsRegistryEditorVersion5.00>>1.reg@echo[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings]>>1.reg@echoProxyEnable=dword:00000000>>1.reg@echoProxyServer=>>1.reg@echoProxyOverride=>>1.regregedit/s1.regdel1.reg@echo设置代理@echoWindowsRegistryEditorVersion5.00>>1.reg@echo[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings]>>1.reg@echoProxyEnable=dword:00000001>>1.reg@echoProxyServer=10.15.0.2:8080>>1.reg@echoProxyOverride=10.*.*.*;192.168.*.*;local>>1.regregedit/s1.regdel1.reg二、以上配合结合,放在一个文件里,可以这样写:网络综合配置.bat@echooffcolor1ftitle网卡&IE代理设置批处理echo实现功能包括切换大连和沈阳网络配置,设置IE代理.goto51job:51jobecho.echo请选择:1:大连,2:沈阳,3:ADSLset/pchoice=请输入相应数字后回车:if/i%choice%==1gotodlnetif/i%choice%==2gotosynetif/i%choice%==3gotoadslgoto51job:adslclscolor1fnetshinterfaceipsetaddressname=本地连接source=dhcpnetshinterfaceipsetdnsname=本地连接source=dhcpclsgotonoproxy:noproxy@echoWindowsRegistryEditorVersion5.00>>1.reg@echo[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings]>>1.reg@echoProxyEnable=dword:00000000>>1.reg@echoProxyServer=>>1.reg@echoProxyOverride=>>1.regregedit/s1.regdel1.reggotoexit:dlnetclscolor1fecho.set/pchoice=输入N后回车跳过网卡设置,直接回车继续网卡设置:if/i%choice%==Ngotoproxyclsecho开始设置大连网络地址!echo正在设置大连IP,请稍等……netshinterfaceipsetaddressname=本地连接source=staticaddr=10.15.100.86mask=255.255.0.0echo正在设置大连网关,请稍等……netshinterfaceipsetaddressname=本地连接gateway=10.15.0.253gwmetric=1echo正在设置大连主DNS,请稍等……netshinterfaceipsetdnsname=本地连接source=staticaddr=10.15.0.1register=PRIMARYecho正在设置大连备用DNS,请稍等……netshinterfaceipadddnsname=本地连接addr=10.100.1.2index=2echo正在设置大连主WINS,请稍等……netshinterfaceipsetwinsname=本地连接source=staticaddr=10.15.0.1echo正在设置大连备用WINS,请稍等……netshinterfaceipaddwinsname=本地连接addr=10.100.1.2index=2echo设置完成!echo正在刷新设置……ipconfig/flushdnsecho显示新的设置:ipconfig/allgotodlproxy:dlproxyclscolor1f@echoWindowsRegistryEditorVersion5.00>>1.reg@echo[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings]>>1.reg@echoProxyEnable=dword:00000001>>1.reg@echoProxyServer=10.15.0.2:8080>>1.reg@echoProxyOverride=10.*.*.*;192.168.*.*;local>>1.regregedit/s1.regdel1.regecho正在关闭浏览器:taskkill/f/t/imIEXPLORE.exeecho正在开启浏览器C:\ProgramFiles\InternetExplorer\IEXPLORE.EXEgotoexit:synetclscolor1fecho.set/pchoice=输入N后回车跳过网卡设置,直接回车继续网卡设置:if/i%choice%==Ngotoproxyclsecho开始设置沈阳网络地址!echo正在设置沈阳IP,请稍等……netshinterfaceipsetaddressname=本地连接source=staticaddr=10.16.100.86mask=255.255.0.0echo正在设置沈阳网关,请稍等……netshinterfaceipsetaddressname=本地连接gateway=10.16.0.253gwmetric=1echo正在设置沈阳主DNS,请稍等……netshinterfaceipsetdnsname=本地连接source=staticaddr=10.16.0.1register=PRIMARYecho正在设置沈阳备用DNS,请稍等……netshinterfaceipadddnsname=本地连接addr=10.100.1.2index=2echo正在设置沈阳主WINS,请稍等……netshinterfaceipsetwinsname=本地连接source=staticaddr=10.16.0.1echo正在设置沈阳备用WINS,请稍等……netshinterfaceipaddwinsname=本地连接addr=10.100.1.2index=2echo设置完成!gotosyproxy:syproxyclscolor1f@echoWindowsRegistryEditorVersion5.00>>1.reg@echo[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings]>>1.reg@echoProxyEnable=dword:00000001>>1.reg@echoProxyServer=10.16.0.2:8080>>1.reg@echoProxyOverride=10.*.*.*;192.168.*.*;local>>1.regregedit/s1.regdel1.regecho正在关闭浏览器:taskkill/f/t/imIEXPLORE.exeecho正在开启浏览器C:\ProgramFiles\InternetExplorer\IEXPLORE.EXEgotoexit:exitclsecho.echo.echo.echo.echo.echo.echo.echo.echo已完成所有设置.echo.echoecho.echo.echo.echo.echo.echo.echo.echo.echo.pauseexit用这种方法就不用建立多个批处理文件,用一个文件做多件事,何乐而不为呢!三、最后介绍一下如何使用VBS脚本来实现大连网络配置.vbsonerrorresumenextstrIPAddress=array(10.15.100.86)strSubnetMask=array(255.255.0.0)strGateway=array(10.15.0.253)strGatewayMetric=array(1)strwinsOne=10.15.0.1strwinsTwo=10.100.1.2strdnsOne=10.15.0.1strdnsTwo=10.100.1.2strComputer=.SetobjShell=CreateObject(Wscript.shell)SetobjWMIService=GetObject(winmgmts:_&{impersonationLevel=impersonate}!\\&strComputer&\root\cimv2)SetcolNetCards=objWMIService.ExecQuery_(Select*FromWin32_NetworkAdapterConfigurationWhereIPEnabled=True)wscript.echo正在进行大连网络配置ForEachobjNetCardincolNetCardserrEnable=objNetCard.EnableStatic(strIPAddress,strSubnetMask)errGateways=objNetCard.