I'm looking for some code/library to programmatically change proxy settings for popular browsers using Ruby on Windows. Thanks.
+2
A:
For Internet Explorer the settings are stored in the Registry (under HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
.) Look for ProxyServer
, ProxyOverride
etc. so these could be modified using Win32::Registry. e.g.
require 'win32/registry'
proxy = "proxy goes here"
Win32::Registry::HKEY_CURRENT_USER.open(
"Software\\Microsoft\\Windows\CurrentVersion\\Internet Settings\\",
Win32::Registry::KEY_WRITE) do |reg|
reg.write("ProxyServer",Win32::Registry::REG_SZ, proxy)
end
For Firefox you would need to determine which profile you wanted to change and could then modify the prefs.js
file. However if Firefox was running at the time then I don't think it wouldn pickup your your change and would rewrite the prefs file with the original value on exiting.
mikej
2009-12-15 12:58:48
This is great information and code. Thanks.
jrhicks
2009-12-15 15:16:12