Remolty access to the registry with WMI

Eric Baelen <[email protected]> Wed, 5 Oct 2005 09:21:34 +0200
Newsgroups gmane.comp.windows.devel.jawin
Message-ID <001601c5c97d$6afa4a10$1a01070a@nberic>
Hi,

I try to access remotely the registry with WMI:

ISWbemLocator wbemLocator = new
ISWbemLocator("WbemScripting.SWbemLocator");
ISWbemServices wbemServices = wbemLocator.ConnectServer("10.7.1.22",
"root/default", "user", "password", "", "", 0, null);

            ISWbemObject wbemObject = wbemServices.Get("StdRegProv", 0,
null);
            System.out.println(wbemObject.GetObjectText_(0).toString());

The System.out.println displays the StdRegProv class definition:

            [Locale(1033), dynamic: ToInstance, provider("RegProv")]
class StdRegProv
{
    [implemented, static] uint32 CreateKey([IN] uint32 hDefKey =
2147483650, [IN] string sSubKeyName);
    [implemented, static] uint32 DeleteKey([IN] uint32 hDefKey =
2147483650, [IN] string sSubKeyName);

            ..

}

As my knowledge of COM is very limited, I'm basically stuck here. In
VBscript samples, it seems very easy:

            Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer( strComputer, "Root\Default",
strUserName, strPassword )
Set objRegistry = objService.Get( "StdRegProv" )
objRegistry.DeleteKey(HKEY_LOCAL_MACHINE,
"SYSTEM\CurrentControlSet\Services\admin51-serv")

Has someone already done this? How can I call EnumValues on my object
wbemObject ?

Thanks for you help
Eric