Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Remote Windows Registry (extramodular)

by nashr (Novice)
on Apr 12, 2006 at 11:17 UTC ( [id://542798]=note: print w/replies, xml ) Need Help??


in reply to Re: Remote Windows Registry (extramodular)
in thread Remote Windows Registry

I've had problems using the system call to pass the "net use" command. I can't get it to work just using "net use \\\\$computer ..." and I've had no success using system("net use \\\\$computer\\ipc\$...." No matter how I delimit the IPC$ parameter, it ignores the $. Very frustrating. I eventually came up with the use Win32::Lanman module used in the following manner (this example gets the OS Version from the registry):
use Win32::TieRegistry(Delimiter => "/", ArrayValues => 0); use Win32::Lanman; $host = "10.10.10.10"; $pass = "yourpass"; $user = "youradmin"; $domain = "yourdomain"; if(!Win32::Lanman::NetUseAdd({remote => "\\\\$host\\ipc\$", password => "$pass", username => "$user", domain => "$domain", asg_type => &USE_IPC})) { print "connect: Sorry, something went wrong; error: "; # get the error code print Win32::Lanman::GetLastError(); exit 1; } $remoteKey = $Registry->{ "//$host/LMachine/SOFTWARE/Microsoft/Windows NT/Curre +ntVersion/ProductName"} or die "Can't read from $host. Error: $^E\n"; print "$remoteKey\n"; if(!Win32::Lanman::NetUseDel("\\\\$host\\ipc\$")) { print "disconnect: Sorry, something went wrong; error: "; # get the error code print Win32::Lanman::GetLastError(); exit 1; }
Hope this helps. If anyone has a more elegant solution, I'd love to hear about it!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://542798]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-19 04:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found