http://www.perlmonks.org?node_id=1080916

pradeep,krishna has asked for the wisdom of the Perl Monks concerning the following question:

Hi fellow monks.
I am new to this TieRegistry module.
The main intention of my scripting now is to:
-> Copy a registry value of the remote server,
-> Delete that entry in the same server and,
-> Write it again after performing some function in the server.

To start with it, as a test script I created the following script:

use Win32::TieRegistry(Delimiter => "/", ArrayValues => 0); $host = "myserver.com"; $remKey= $Registry->Connect($host,"LMachine/",{ Access=>KEY_READ, Deli +miter=>"/" } ); $remoteKey = $Registry->{"//$host/LMachine/SOFTWARE/Microsoft/Windows +NT/CurrentVersion/ProductName"} or die "Can't read from $host. Error: + $^E\n"; print "$remoteKey\n";
When I compile this code I am getting the erred output saying :Can't read from ilbtdb1.jdadelivers.com. Error: The handle is invalid

help me in solving this.
Thanks in advance.

Replies are listed 'Best First'.
Re: Problem connecting the remote machine in using TieRegistry.
by pradeep,krishna (Scribe) on Apr 03, 2014 at 10:15 UTC

    I had missed to connect to the server. Now i made changes to my code as bellow:

    use Win32::TieRegistry(Delimiter => "/", ArrayValues => 0); $host = "myserver.com"; $password='password'; $domain='myserver'; $login = 'my_admin'; $op=`net use \\\\$host\\ipc\$ \"$password\" \/user:$domain\\$login`; $remoteKey = $Registry->{"//$host/LMachine/SOFTWARE/Microsoft/Windows +NT/CurrentVersion/ProductName"} or die "Can't read from $host. Error: + $^E\n"; print "$remoteKey\n";
    Now I am getting the perfect output.