title: Setting IE proxy values using VBscript
body: <p>I've written a small piece of vb script to set the proxy settings</p>
  
  <hr>
  
  <pre><code>'begin script
  Option Explicit
  Dim valUserIn
  Dim objShell, RegLocate
  Set objShell = WScript.CreateObject("WScript.Shell")
  RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable"
  objShell.RegWrite RegLocate,"0","REG_DWORD"
  WScript.Sleep(5000)
  valUserIn = Inputbox("Enter the Proxy server you want to use.","Proxy Server Required","proxygate.mydomain.com:8080")
  if valUserIn = "" then
      RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable"
      objShell.RegWrite RegLocate,"0","REG_DWORD"
      'MsgBox "No proxy mode"
  else
      RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer"
      objShell.RegWrite RegLocate,valUserIn,"REG_SZ"
      RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable"
      objShell.RegWrite RegLocate,"1","REG_DWORD"
      'MsgBox "Proxy mode: " &amp; valUserIn
  end if
  WScript.Quit
  'end script
  </code></pre>
  
  <hr>
  
  <p>Now the script runs properly and it is able to set the registry value. If I use Internet Explorer there are no issues i.e. the browser uses the correct proxy settings (as entered in the input dialog or 'no proxy' if cancelled) server.</p>
  
  <p>However when Firefox or Chrome are used (tried with different versions) when the browser behaves oddly. Sometimes the correct proxy server is used however at times the browser displays a message the proxy server is refusing connections (basically it was not able to reach the proxy server). Moreover this behavior is random, it is not based on idle time of the browser or the number of requests/clicks.</p>
  
  <p>One more analysis which I have done is, whenever this happens if I open up internet explorer's options dialog and click on LAN settings (where the proxy can be changed) I notice that the proxy settings are set properly. If I simply click on Cancel and exit the dialog the browsers start using the correct settings.</p>
  
  <p>Any tips on what Internet explorer does and how we can automate that in the script????</p>
  
  <p>Thanks and Regards</p>