我想制作一个简单的 Windows 桌面小部件来打开和关闭互联网代理。
什么方法比较简单?
最佳答案
您可以使用 Visual Basic 脚本和批处理创建一个简单的“小部件”。
例子:
proxy_off.bat
echo off
cls
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
change_shortcut_on
exit
proxy_on.bat
echo off
cls
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
change_shortcut_off
exit
change_shortcut_off.vbs
Set sh = CreateObject("WScript.Shell")
Set shortcut = sh.CreateShortcut("C:\Users\%USERNAME%\Desktop\Proxy.lnk")
shortcut.TargetPath = "C:\Users\%USERNAME%\Proxy Settings\proxy_off.bat"
shortcut.IconLocation = "C:\Users\%USERNAME%\Proxy Settings\Icons\on.ico"
shortcut.Save
change_shortcut_on.vbs
Set sh = CreateObject("WScript.Shell")
Set shortcut = sh.CreateShortcut("C:\Users\%USERNAME%\Desktop\Proxy.lnk")
shortcut.TargetPath = "C:\Users\%USERNAME%\Proxy Settings\proxy_on.bat"
shortcut.IconLocation = "C:\Users\%USERNAME%\Proxy Settings\Icons\off.ico"
shortcut.Save
说明:
- 在“C:\Users\%USERNAME%\”中创建文件夹“Proxy Settings”;
- 在“C:\Users\%USERNAME%\Proxy Settings\”中创建文件夹“Icons”;
- 在“C:\Users\%USERNAME%\Proxy Settings\Icons”中插入“on.ico”(代理“开启”的任何图标)和“off.ico”(代理“关闭”的任何图标) ;
- 在“C:\Users\%USERNAME%\Proxy Settings\”中创建上述文件(proxy_off.bat、proxy_on.bat、change_shortcut_off.vbs、change_shortcut_on.vbs);
- 在您的桌面上创建“C:\Users\%USERNAME%\Proxy Settings\proxy_off.bat”的快捷方式 (Proxy.lnk);
完成!非常简单有效。 现在您可以单击“Proxy.lnk”(桌面上的快捷方式)来“打开”和“关闭”代理。
代理开启 代理关闭
图标网址:http://s30.postimg.org/sgoerz0od/image.png
关闭图标网址:http://s13.postimg.org/9zha38zkj/off.png
关于用于打开和关闭代理的 Windows 桌面小部件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26708347/