Windows desktop widget to turn proxy on and off

后端 未结 2 721
臣服心动
臣服心动 2021-02-06 16:39

I want to make a simple Windows desktop widget to turn on and off the internet proxy.

What is the simpler way?

2条回答
  •  北荒
    北荒 (楼主)
    2021-02-06 17:18

    You can create a simple "widget" using Visual Basic scripts and batchs.

    Example:

    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
    

    Instructions:

    • Create the folder "Proxy Settings" in "C:\Users\%USERNAME%\";
    • Create the folder "Icons" in "C:\Users\%USERNAME%\Proxy Settings\";
    • Insert the "on.ico" (any icon for proxy "On") and "off.ico" (any icon for proxy "Off") in "C:\Users\%USERNAME%\Proxy Settings\Icons";
    • Create the above files in "C:\Users\%USERNAME%\Proxy Settings\" (proxy_off.bat, proxy_on.bat, change_shortcut_off.vbs, change_shortcut_on.vbs);
    • Create a shortcut (Proxy.lnk) to "C:\Users\%USERNAME%\Proxy Settings\proxy_off.bat" in your Desktop;

    Done! Very simple and effective. Now you can click on "Proxy.lnk" (the shortcut in your Desktop) to turn your proxy "On" and "Off".

    Proxy On         Proxy Off

    Proxy On   Proxy Off

    On icon url: http://s30.postimg.org/sgoerz0od/image.png
    Off icon url: http://s13.postimg.org/9zha38zkj/off.png

提交回复
热议问题