bat file to tick ar untick using proxy in PC

It's that time of the day, leaving office and sit at home, turn on your laptop, you need to disable using the proxy on PC level from control panel > internet options > connections > proxy off... next morning, same thing at office, again go all this to enable it again... next find the inetcpl.cpl from Run to make sure to reach to that dialog easier tick/un-tick and say OK

it is annoying, i wanted to have bat file or reg key to make this one click instead of doing it all the time! nothing worked after too many searches and trying many scenarios..

I know browsers have proxy enable/disable addons, and work fine in Chrome and so, but for everything to work need to do it from Internet options so to have it on PC level...

Any working idea is welcome

Thanks

1

1 Answer

Without words :-)

:: EnableProxy
@Echo off
set "Key=HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Set "Val=ProxyEnable"
Set "Typ=REG_DWORD"
Reg add "%Key%" /v %Val% /t %Typ% /d "0x1" /f
:: Disable Proxy
@Echo off
set "Key=HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Set "Val=ProxyEnable"
Set "Typ=REG_DWORD"
Reg add "%Key%" /v %Val% /t %Typ% /d "0x0" /f
:: ToggleProxy.cmd
@Echo off
set "Key=HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Set "Val=ProxyEnable"
Set "Typ=REG_DWORD"
for /f "tokens=3" %%R in ( 'Reg Query "%Key%" /v %Val% ^|find /i "%Val%"'
) do if "%%~R" equ "0x0" ( Reg add "%Key%" /v %Val% /t %Typ% /d "0x1" /f
) else ( Reg add "%Key%" /v %Val% /t %Typ% /d "0x0" /f
)

I wrote a similar one on StackOverflow to toggle between two different Proxies.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like