|
Re: Remolty access to the registry with WMI: msg#00005windows.devel.jawin
Tx Gabor, It works. Your code made me to realize that before getting a value, I need the sub-keys below SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall So I tried: Variant.ByrefHolder outValueRef = new Variant.ByrefHolder(new String[] {""}); Object[] objs = new Object[3]; objs[0] = new Integer(0x80000002); objs[1] = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; objs[2] = outValueRef; result = (Integer) lSWbemObjectRegProv.invokeN("EnumKey", objs); I receive: org.jawin.COMException: 8002000d: Memory is locked So I tried different variations of outValueRef like outValueRef = new Variant.ByrefHolder(new String[0]); -> access violation or outValueRef = new Variant.ByrefHolder(new String[1000]); -> memory lock I also initialized all the 1000 Strings, still memory lock. Any idea? Regards Eric -----Original Message----- From: Discussion of Java/Win32/COM integration with Jawin [mailto:JAWIN@xxxxxxxxxxxxxxxxxxx] On Behalf Of Gábor Móczár Sent: Wednesday, October 05, 2005 4:43 PM To: JAWIN@xxxxxxxxxxxxxxxxxxx Subject: Re: [JAWIN] Remolty access to the registry with WMI Hi! This works for me, but we are using tomcat and this code sometimes freezes the whole system. I think that the memory reference (which holds the return value) which is provided by the wmi, sometimes invalid... public Vector getRegistryValue(String ServerIP, String ServerUserid, String ServerPassword, String ServerDomain, String SubKey, String ValueName, String ValueType) throws COMException { DispatchPtr lWMISWbemLocator = null; Integer result = new Integer(1000); String retValue = new Variant().pbstrVal; Vector res = new Vector(); String DomainAndUser = null; if ("".equals(ServerUserid)) { DomainAndUser = ""; } else { if ("".equals(ServerDomain)) { DomainAndUser = ServerIP + "\\" + ServerUserid; } else { DomainAndUser = ServerDomain + "\\" + ServerUserid; } } lWMISWbemLocator = new DispatchPtr("WbemScripting.SWbemLocator"); DispatchPtr lSWbemObject = (DispatchPtr) lWMISWbemLocator.invoke("ConnectServer", ServerIP, "root\\default", DomainAndUser, ServerPassword); DispatchPtr lSWbemObjectRegProv = (DispatchPtr) lSWbemObject.invoke("Get", "StdRegProv"); Variant.ByrefHolder outValueRef = new Variant.ByrefHolder(new String()); Object[] objs = new Object[4]; objs[0] = new Integer(0x80000002); objs[1] = SubKey; objs[2] = ValueName; objs[3] = outValueRef; String regType = null; if (ValueType.equals("STRING")) regType = "GetStringValue"; if (ValueType.equals("MULTISTRING")) regType = "GetMultiStringValue"; result = (Integer) lSWbemObjectRegProv.invokeN(regType, objs); retValue = (String) outValueRef.getRef(); res.add(result); res.add(retValue); return res; } Regards, Gabor -----Original Message----- From: Discussion of Java/Win32/COM integration with Jawin [mailto:JAWIN@xxxxxxxxxxxxxxxxxxx]On Behalf Of Christophe Warland (FRSGlobal) Sent: Wednesday, October 05, 2005 4:36 PM To: JAWIN@xxxxxxxxxxxxxxxxxxx Subject: Re: [JAWIN] Remolty access to the registry with WMI How about using arrays? i.e. : names = new Variant.ByrefHolder(new String[0]); types = new Variant.ByrefHolder(new int[0]); -----Original Message----- From: Discussion of Java/Win32/COM integration with Jawin [mailto:JAWIN@xxxxxxxxxxxxxxxxxxx] On Behalf Of Eric Baelen Sent: Wednesday, October 05, 2005 4:31 PM To: JAWIN@xxxxxxxxxxxxxxxxxxx Subject: Re: Remolty access to the registry with WMI I progress in my investigation. I call the method EnumValues on the StdRegProv object. The method has the following signature: uint32 EnumValues([IN] uint32 hDefKey = 2147483650, [IN] string sSubKeyName, [out] string sNames[], [out] sint32 Types[]) I try to do something like that: Variant.ByrefHolder names = new Variant.ByrefHolder(new String()); Variant.ByrefHolder types = new Variant.ByrefHolder(new Integer(0)); wbemObject.invokeN("EnumValues ", new Object[] { RegistryConstants.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", names, types}); but after names.getRef() is null Any idea? Tx Eric -----Original Message----- From: Discussion of Java/Win32/COM integration with Jawin [mailto:JAWIN@xxxxxxxxxxxxxxxxxxx] On Behalf Of Eric Baelen Sent: Wednesday, October 05, 2005 9:22 AM To: JAWIN@xxxxxxxxxxxxxxxxxxx Subject: [JAWIN] Remolty access to the registry with WMI 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 |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Remolty access to the registry with WMI: 00005, Gábor Móczár |
|---|---|
| Next by Date: | Invoke with an string array as out parameter: 00005, Eric Baelen |
| Previous by Thread: | Re: Remolty access to the registry with WMIi: 00005, Gábor Móczár |
| Next by Thread: | Invoke with an string array as out parameter: 00005, Eric Baelen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |