Well, since you called me on it, I might as well step up to the plate and give it a shot. The $HKEY_CURRENT_USER variable might be defined by the module you're using. I can't tell what module that is, since you conveniently chopped off the top of your script. If you didn't leave anything out, then there's a major part of your problem right there. Are you using Win32::Registry? If so, I'd recommend Win32::TieRegistry (see below).
One thing I'm noticing is that it looks like you're trying to open a key at HKEY_CURRENT_USER/thiskey/test. Do you have a key there? If not, then I don't think that the ->Open method will create one for you. I might be wrong. Also, can you put a space between the method name and the parameters? Here's a little code that should get you started using Win32::TieRegistry. I'm doing this off the top of my head, but it should give you an idea of how it works. There are a lot of functions, such as the ->Open and ->Connect method, that are usually not necessary, and in fact might just complicate your program. Your mail program might kill one or two of the lines, so watch for wrapping. ########################### use strict; use Win32::TieRegistry(Delimiter => "/"); #the delimiter part makes it a lot more readable than using "\\" print "These programs run when you start Windows.\n\n"; #NOTE: $Registry is defined by the module my $computer = "tojo2000"; #NOTE: Notice that I didn't have to call Open or Connect #methods. The $Registry virtual root does this automagically my $regkey = $Registry->{"//$computer/HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/Curre ntVersion/Run"} || die "No Run key found!"; print "Description\tProgram\n\n"; #Notice how I can get the keys by dereferencing the #object we just made. foreach(sort keys %{$regkey}){ print "$_\t${$regkey}{$_}\n"; } print "Creating new key...\n"; #Finally, we create a new, empty key. my $soft = $Registry->{"//$computer/HKEY_CURRENT_USER/Software"}|| die "Error opening key!"; $soft->{"FooSoft"} = {} || die "Couldn't create new key!"; #For one last example, let's add a value to the key $soft->{"FooSoft/Version"} = "0.0.0000" || die "Error adding value!"; print "Created HKCU/Software/FooSoft and set the Version value.\n"; ############################## <MyOpinion> BTW, reading the registry remotely is VERY fast. It's one of the things I think Microsoft did right. Having to dig through as much information as is in the Registry remotely from one file, much less several dozen .ini files would be a nightmare over a WAN connection, but you can get/set information quickly with the Registry because it is in memory. Of course, that does mean that we should be as responsible as possible about who gets to write to it and read from it... </MyOpinion> -----Original Message----- From: drieux To: begin begin Sent: 5/19/02 11:35 PM Subject: Re: Writing to the Windows registry On Sunday, May 19, 2002, at 11:01 , Postman Pat wrote: [..] > I obviously did something from here coz this does not work. > --- Start code --- > print ("Inserting registry settings [@ARGV[$i]]\n"); > my $Register = "thiskey/test"; > my $hkey; > > $HKEY_CURRENT_USER->Open ($Register,$hkey) || die ("Cannot open > registry\n"); > undef my $garbage; > $hkey->SetValueEx("TestValue",$garbage,REG_SZ,"Friggin test"); > $hkey->Close; > --- End code --- > It dies & returns cannot open the registry. where did you define $HKEY_CURRENT_USER I did not see this asserted anywhere. secondly you may find help with use strict; and calling perl with '-w'. also, trivial detail I tend to like no space between the method and the (...) $HKEY_CURRENT_USER->Open($Register,$hkey) also - you declare '$hkey' but never set it to anything a la some sort of $hkey = foo::bar->new(@argFoo); hence it would not be able to invoke any methods.... but I shall of course defer to anyone who grok's the Win32::* space.... Yo, Timothy - this be one of your HomeBoys, so Give It up. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]