开发者

Change Windows browser proxy settings via ruby script

开发者 https://www.devze.com 2022-12-13 20:59 出处:网络
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 i

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消