ActiveState Powered by ActiveState

ActiveState Community


Remote Registry EnumKey via WMI and Perl

Posted by jcluff on 2007-11-26 17:54
OS: Windows

I have been pounding my head against the wall to get perl to pull info from a remote registry using the WMI. I have to stick with the WMI instead of just using Win32::OLE because I need to be able to use credentials other than the user's current login credentials. Specifically if the user is running the script from a system not part of the AD Domain.

Anywho I am trying to enumerate registry subkeys. I have looked at a lot of sample code such as this code from www.activexperts.com.

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SYSTEM\CurrentControlSet\Services"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
 
For Each subkey In arrSubKeys
    Wscript.Echo subkey
Next

the problem for me lies in the line oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

it seems to be that it is declaring arrSubKeys from the Method EnumKey which it stuff all of the subkeys in as an array. I don't know how to emulate this and get it to populate the variable in Perl. If somebody could write a similar script in perl that work as an example for me I would be most appreciative.

-->