Windows Registry tool.

Discussion in 'Ruby' started by Gregory Brown, Mar 31, 2006.

  1. The code:

    require 'win32ole';class P;def initialize;@s=3DWIN32OLE.new "WScript.Shell"=
    ;
    @p=3D"";end;def p p;@p=3Dp;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?
     
    Gregory Brown, Mar 31, 2006
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark
    Replies:
    0
    Views:
    555
  2. Gerard Marshall Vignes
    Replies:
    1
    Views:
    407
    Gerard Marshall Vignes
    Jul 23, 2003
  3. HK
    Replies:
    1
    Views:
    4,216
    Cowboy \(Gregory A. Beamer\)
    Apr 1, 2004
  4. Replies:
    0
    Views:
    972
  5. Roedy Green

    poking and reading Windows Registry

    Roedy Green, Jul 19, 2003, in forum: Java
    Replies:
    1
    Views:
    985
    Eugene Toporov
    Jul 22, 2003
  6. Leny
    Replies:
    3
    Views:
    17,190
    Daniel
    Feb 1, 2005
  7. Rob Schieber

    Web Service Registry tool

    Rob Schieber, Oct 14, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    133
    Rob Schieber
    Oct 14, 2005
  8. Collin Miller
    Replies:
    10
    Views:
    964
    Roger Pack
    Jul 9, 2010
Loading...