Ruby – Read/Write ProxyServer details in Windows registry

Ruby – Read/Write ProxyServer details in Windows registry

Code:

require ‘win32/registry’

def get_proxy
path = ‘Software\Microsoft\Windows\CurrentVersion\Internet Settings’
type, value =     Win32::Registry::HKEY_CURRENT_USER.open(path).read (’ProxyServer’)
puts value
end

def set_proxy
path = ‘Software\Microsoft\Windows\CurrentVersion\Internet Settings’
name=’ProxyServer’
data=’socks=34.12.78.92:54323′
type=1

Win32::Registry::HKEY_CURRENT_USER.open (path,Win32::Registry::KEY_WRITE).write(name,type,data)
end

get_proxy
set_proxy
get_proxy

Output:

socks=68.42.78.102:56773
socks=34.12.78.92:54323

Comments

Nice

great article ;)

~Uma