Forum: Ruby Windows Registry tool.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Gregory B. (Guest)
on 2006-03-31 19:15
(Received via mailing list)
The code:

require 'win32ole';class P;def initialize;@s=WIN32OLE.new
"WScript.Shell";
@p="";end;def p p;@p=p;end;def sk k,v;@s.RegWrite "#{@p}\\#{k}", v;end;
def gk(k);@s.RegRead "#{@p}\\#{k}";end;def i(file);`regedit /s #{file}`;
end;end;puts P.new.instance_eval(ARGF.read)

Usage:

point at a script or input from stdin

do something like this:

p 'HKEY_LOCAL_MACHINE\Software\gaim'
sk 'apple', 'banana'

or

i  'something.reg'
p 'A\path\that\should\have\changed'
gk 'this_key_should_be_different'


Full list of commands:

p - sets the 'path'
i  - imports a registry file
sk - sets a key to the specified value
gk - gets the value of the given key

This program will print out the value of the evaluated code.  (i.e.
the last line executed)

Sorry for the golfing and the ugly interface.  I was just playing
around and came up with this, and though maybe someone might find it
useful?
This topic is locked and can not be replied to.