Fast way to switch off proxy in Windows

3

1

Whenever I connect to a corporate VPN it always sets a proxy server. It is necessary for corporate WiFi but this proxy is inaccessible from internet.

This means that whenever I connect from home WiFi I cannot open any page except internal network.

The solution is to click on Start, Control Panel, Network and Internet, Internet options, Connection, Local network setting and switch off proxy checkbox there. This procedure is annoying.

I would like to have some bat script that turns it off. Could you help me?

Leos Literak

Posted 2015-10-16T15:35:30.260

Reputation: 351

Possible duplicate of How do I change the Windows7 LAN proxy config from the command line?

– pun – 2015-10-16T15:41:23.620

It really looks like duplicate. Unfortunatelly running netsh winhttp show proxy returns same result regardless of the proxy checkbox state. Weird. – Leos Literak – 2015-10-16T15:58:50.703

This is a better duplicate, but requires the combination of two of the answers: How can I change the system proxy from the command line?. I've done this below in my answer.

– DavidPostill – 2015-10-16T16:34:11.093

Answers

3

How do I switch off the proxy from a batch file?

Solution 1:

Use the following batch file:

@echo off
netsh winhttp reset proxy

Notes:

Solution 2:

  1. Configure the proxy manually using the GUI, then export the registry entries for a disabled proxy [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings].

    See answer How can I change the system proxy from the command line? by zelanix for more information about this step.

    See also How to configure client proxy server settings by using a registry file by Microsoft.

  2. Write a batch file for subsequent use which:

    • Imports the registry file created as above.
    • Uses the netsh winhttp import proxy source=ie command.
  3. Use this batch file in future to disable your proxy.


Further Reading

DavidPostill

Posted 2015-10-16T15:35:30.260

Reputation: 118 938

You're welcome. Please feel free to accept my answer. ;)

– DavidPostill – 2015-10-16T15:49:44.767

Hmm, I found nothing. The script has no effect. Dump says: pushd winhttp reset proxy popd. Show proxy always says that I have direct access without proxy, even when proxy is set and turned on. Any idea? – Leos Literak – 2015-10-16T16:09:54.903

@LeosLiterak Answer expanded to outline a second solution. – DavidPostill – 2015-10-16T16:31:57.163

It seems that only this registry item changes: "ProxyEnable"=dword:00000001 – Leos Literak – 2015-10-17T13:48:56.573

@LeosLiterak That makes it a little easier then ;) – DavidPostill – 2015-10-17T13:56:56.970

That is really weird. When I run this script (regedit /S proxyoff.reg netsh winhttp import proxy source=ie), chrome does not work. Then I open windows GUI and I can check that proxy is unset. Then I close this screen with Cancel and chrome starts to work! – Leos Literak – 2015-10-17T14:06:01.690

Did you restart Chrome after running the script? – DavidPostill – 2015-10-17T14:08:37.470

No. That would be bad as well. I do not want to loose all my work. I just want to continue. – Leos Literak – 2015-10-17T14:09:48.297

Ok. I was just curious if a Chrome restart would fix that last remaining issue. If it does then somehow Chrome needs to be informed the proxy has changed. That could be a bug in Chrome. In any case I don't know how to fix it :/ Presumably opening/closing the GUI screen does something in addition (sends a Windows message to all open applications maybe), the question is what. – DavidPostill – 2015-10-17T14:13:25.990

I wonder if it is worth asking a new question, with our current solution and saying it doesn't work with Chrome (although it should). That might get some more eyeballs on it. – DavidPostill – 2015-10-17T14:14:37.247

In any case, you can surely configure Chrome to reopen all it's current tabs on a restart? Firefox has had that option for a long time. – DavidPostill – 2015-10-17T14:16:23.693

1

I use the SETPROXY tool from the command line, or in combination with SlickRun, where I assigned some magic words using it. The author of both is the well respected original developer of Fiddler Eric Lawrence.

Examples:

SETPROXY myproxyserver:8888
SETPROXY none

Borislav Ivanov

Posted 2015-10-16T15:35:30.260

Reputation: 297