Want more features on Pastebin? Sign Up, it's FREE!
Guest

Win32/Registry Write and Read

By: Predatorian on Nov 6th, 2013  |  syntax: Ruby  |  size: 0.84 KB  |  views: 35  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. irb(main):012:0> Win32::Registry::HKEY_CURRENT_USER.open('Environment', Win32::Registry::KEY_WRITE) do |reg|
  2. irb(main):013:1* puts reg['Path']
  3. irb(main):014:1> end
  4. Win32::Registry::Error: Access is denied.
  5.         from C:/ruby/Ruby193/lib/ruby/1.9.1/win32/registry.rb:587:in `read'
  6.        from C:/ruby/Ruby193/lib/ruby/1.9.1/win32/registry.rb:621:in `[]'
  7.        from (irb):13:in `block in irb_binding'
  8.         from C:/ruby/Ruby193/lib/ruby/1.9.1/win32/registry.rb:389:in `open'
  9.        from C:/ruby/Ruby193/lib/ruby/1.9.1/win32/registry.rb:496:in `open'
  10.        from (irb):12
  11.        from C:/ruby/Ruby193/bin/irb:12:in `<main>'
  12. irb(main):015:0> Win32::Registry::HKEY_CURRENT_USER.open('Environment', Win32::Registry::KEY_READ) do |reg|
  13. irb(main):016:1* puts reg['Path']
  14. irb(main):017:1> end
  15. C:\Program Files (x86)\Nmap
  16. => nil
  17. irb(main):018:0>
clone this paste RAW Paste Data