Thanks for the suggestion, but here is how I finally ended up doing it
and it does what I needed:

@lic_servers = ("nike0",
                "dhps",
                "gksc",
                "fhd6",
                "FM6S",
);

foreach $lic_serv (@lic_servers)
{       
system ("reg add HKLM\\SOFTWARE\\Atria\\ClearCase\\CurrentVersion \/f
\/v LicenseHost \/t REG_SZ \/d \"$lic_serv\"");
system ("get_clearlicense.pl license.txt $lic_serv");
}

David Nazary

-----Original Message-----
From: Chris Devers [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 20, 2005 11:47 AM
To: Nazary, David
Cc: Perl Beginners - CGI List
Subject: Re: Mmodifing Windows registry key

On Mon, 20 Jun 2005, Nazary, David wrote:

> I want to run a script in a continuous loop so that each time it runs 
> it will modify a registry key and get the data against the new key.
> 
> Basically, I need to use "reg.exe UPDATE" command from inside a perl 
> script. Is it possible?

Yes, but why would you do it that way? Windows Perl provides ways to 
poke at the registry directly, without having to invoke reg.exe by hand.


It would make far more sense to do things with a CPAN module. A quick 
Google / CPAN search suggests that Win32::TieRegistry is the way to go; 
there's an older Win32::Registry, but several sources I found claim that

it is obsolete & Win32::TieRegistry is the best option available now.

    <http://search.cpan.org/~tyemq/Win32-TieRegistry/TieRegistry.pm>
    <http://www.xav.com/perl/site/lib/Win32/TieRegistry.html>

Quoting from (& reformatting) the beginning of the documentation...


    SYNOPSIS

      use Win32::TieRegistry 0.20 ( UseOptionName=>UseOptionValue[,...]
);
      $Registry->SomeMethodCall(arg1,...);
      $subKey                      = $Registry->{"Key\\SubKey\\"};
      $valueData                   =
$Registry->{"Key\\SubKey\\\\ValueName"};
      $Registry->{"Key\\SubKey\\"} = { "NewSubKey" => {...} };
      $Registry->{"Key\\SubKey\\\\ValueName"} = "NewValueData";
      $Registry->{"\\ValueName"}   = [ pack("fmt",$data), REG_DATATYPE
];

    EXAMPLES

      use Win32::TieRegistry( Delimiter=>"#", ArrayValues=>0 );
      $pound      = $Registry->Delimiter("/");
      $diskKey    = $Registry->{"LMachine/System/Disk/"}
                  or die "Can't read LMachine/System/Disk key: $^E\n";
      $data       = $key->{"/Information"}
                  or die "Can't read LMachine/System/Disk//Information
value: $^E\n";
      $remoteKey  = $Registry->{"//ServerA/LMachine/System/"}
                  or die "Can't read //ServerA/LMachine/System/ key:
$^E\n";
      $remoteData = $remoteKey->{"Disk//Information"}
                  or die "Can't read ServerA's System/Disk//Information
value: $^E\n";
      foreach $entry (  keys(%$diskKey)  ) {
          ...
      }
      foreach $subKey (  $diskKey->SubKeyNames  ) {
          ...
      }
      $diskKey->AllowSave( 1 );
      $diskKey->RegSaveKey( "C:/TEMP/DiskReg", [] );


I'm not a Windows programmer, so I can't vouch for how well this stuff 
work in practice, but it looks pretty straightforward to use. Both 
versions of the documentation linked above provide lots of examples of 
both reading & writing registry keys, so there should be a method that 
maps well to the kind of work that you're doing. 
 
 

-- 
Chris Devers

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to