`

使用bat批处理脚本自动设置IP和IE代理

 
阅读更多

在不同的网络环境间切换时需要手动修改IP和IE代理设置,较为繁琐,可以通过编写相应的bat批处理脚本自动完成配置,做到一键切换。以下是一个示例:

@echo off

::echo set ip...
::netsh interface ip set address name="本地连接" source=static addr=xxx.xxx.xxx.xxx mask=xxx.xxx.xxx.xxx

::echo set gateway....
::netsh interface ip set address name="本地连接" source=static gateway=xxx.xxx.xxx.xxx gwmetric=1

echo set IE proxy: xxx.xxx.xxx.xxx:8080
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 "xxx.xxx.xxx.xxx:8080" /f
::跳过本地地址的代理服务器
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d "<local>" /f

echo flash...
ipconfig /flushdns


其中xxx.xxx.xxx.xxx为对应属性的IP。如第11行中的"xxx.xxx.xxx.xxx:8080"为目标代理服务器的IP和端口(8080),两者都可以根据自己的环境修改。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics