I'm looking for some code/library to programmatically change proxy settings fo开发者_StackOverflow中文版r popular browsers using Ruby on Windows. Thanks.
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.
精彩评论