in reply to Adding Registry Keys & Values

Take a look at Win32::TieRegistry. This example creates foo, and set its value to bar. This same syntax is also good for modification: Change bar to whatever you want, and run the script again, you should see the value change.

use Win32::TieRegistry; $registry = Win32::TieRegistry->new("CUser"); $registry->SetValue("foo", "bar");

This sets a new value under HKEY_CURRENT_USER/AppEvents:

use Win32::TieRegistry; $registry = Win32::TieRegistry->new("CUser/AppEvents", {Delimiter => " +/"}); $registry->SetValue("foo", "something");

This creates a new key (or a path if you want to call it this way):

use Win32::TieRegistry; $registry = Win32::TieRegistry->new("CUser", {Delimiter => "/"}); $registry->CreateKey("foo");

Replies are listed 'Best First'.
Re^2: Adding Registry Keys & Values
by Jenda (Abbot) on Nov 10, 2004 at 22:09 UTC

    And now for something completely the same using a different module. (Win32::Registry > 0.07 or Win32::Registry <= 0.07 plus the patch)

    use Win32::Registry; $HKCU->SetValues( "foo", REG_SZ, "bar"); $HKCU->Open("AppEvents")->SetValues( "foo", REG_SZ, "something"); #or #Win32::Registry::SetValues( 'HKEY_CURRENT_USER\AppEvents', # "foo", REG_SZ, "something"); $HKCU->Create("foo");

    Jenda
    We'd like to help you learn to help yourself
    Look around you, all you see are sympathetic eyes
    Stroll around the grounds until you feel at home
       -- P. Simon in Mrs. Robinson

      Thanks very much Jenda, But I had a bit of a slap rist here once for using Win32::Registry for being obselete.

      Thanks indeed.
Re^2: Adding Registry Keys & Values
by tye (Sage) on Nov 10, 2004 at 23:36 UTC

    I'd do it like this:

    use strict; use Win32::TieRegistry qw( $registry Delimiter / ); $registry->{"CUser/AppEvents//foo"}= "something";

    As for

    I have never used Win32::TieRegistry module before, so I wouldn't know where to start from.

    I'd think you'd start by reading the documentation for Win32::TieRegistry which is fairly complete and includes lots of "quick start" material.

    - tye        

      I forgot to say "its a remote registry"!

      So my question now is how do I do the same if its a remote PC?

      Ah,..The Win32::TieRegistry documents.

      Thanks very much Tye,..can I call you Tye?
        So my question now is how do I do the same if its a remote PC?
        You read the documentation .