0

I cannot figure out how to turn the Web Proxy off when I close the console. My current code:

AppDomain.CurrentDomain.ProcessExit += delegate(object sender, EventArgs e)
        {
           RegistryKey inetproxyRegKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true); 
            inetproxyRegKey.SetValue("ProxyEnable", 0);
   }
  • 3
    Please explain what the problem you are having is? Does the code execute? – Ashigore Nov 17 '13 at 23:13
  • possible duplicate of [Programmatically Set Browser Proxy Settings in C#](http://stackoverflow.com/questions/197725/programmatically-set-browser-proxy-settings-in-c-sharp) – Ashigore Nov 17 '13 at 23:16

1 Answers1

0
static void Main(string[] args)
        {
            /*
            Your Code here
            */


            AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);

        }
        static private void CurrentDomain_ProcessExit(object sender, EventArgs e)
        {
            RegistryKey inetproxyRegKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
            inetproxyRegKey.SetValue("ProxyEnable",1);

        }
Sudhakar Tillapudi
  • 25,935
  • 5
  • 37
  • 67