windows批处理命令通过修改注册表快捷开关Internet代理

来源:互联网 发布:高铁无缝钢轨原理 知乎 编辑:程序博客网 时间:2024/05/16 11:10
在公司上网很不爽,因为在公司要接入外网的时候需要设置一下internet代理,回到公寓以后又要把代理关掉才好,于是感觉很麻烦就萌生起了写个小脚本来开关internet代理,脚本很简单,使用windows批处理语句实现,通过操作注册表proxy相关项来实现修改注册表对应值得方式来实现。新建一个txt文档,写入下面的代码,另存成.bat文件,每次使用时双击。该段代码会自动判断目前代理情况,并对其进行修改。


@echo off


title Proxy Auto Config
echo judging current proxy configuration...
for /f "tokens=3" %%i in ('
reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v "ProxyEnable"')  do set val=%%i%


echo modify proxy configuration...
if %val%==0x1 
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v "ProxyEnable" /t REG_DWORD /d 0 /f
if %val%==0x0 
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v "ProxyEnable" /t REG_DWORD /d 1 /f
:end


echo proxy mode has been changed...


怎么样,很简单吧,还不快去试试骚年~
原创粉丝点击