Results 1 to 5 of 5
- 02-10-2011, 12:07 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
Jni registry 'access denied' error.
Hi,
First of all .. I post this question in this forum, because the original component site (JNIRegistry) does not provide a dedicated forum, nor a mailing list.
Second, I have checked google here and there, but I was not able to find an answer ..
I have a problem reading the remote registry with my Java application (software scanning application). My application runs fine on Windows XP, but fails to scan computers, while the scanning computer is running Windows 7. I have disabled the UAC on Windows 7, but I still get this error:
Error:
INFO [ scanForSoftware() ] - gdmpc386( Adrian Dumitru ): scanning started ..
INFO [ connect() ] - 'net use' exit value = 0
INFO [ scanForSoftware() ] - gdmpc386: com.ice.jni.registry.RegistryException: Registry API Error 5, 'access denied' - 'RegOpenKeyEx()'
com.ice.jni.registry.RegistryException: Registry API Error 5, 'access denied' - 'RegOpenKeyEx()'
at com.ice.jni.registry.RegistryKey.openSubKey(Native Method)
at gdm.softauditor.model.ComputerModel.scanForSoftwar e(ComputerModel.java:398)
at gdm.softauditor.model.ComputerModel.scan(ComputerM odel.java:729)
at gdm.softauditor.SoftwareAuditorAgent.customCompute rSource(SoftwareAuditorAgent.java:124)
at gdm.softauditor.SoftwareAuditorAgent.main(Software AuditorAgent.java:105)
INFO [ scanForSoftware() ] - gdmpc386( Adrian Dumitru ): 0 software entries found.
INFO [ scanForSoftware() ] - gdmpc386( Adrian Dumitru ): scanning completed ..
INFO [ main() ] - 1 computers successfully scanned.
INFO [ main() ] - Application completed ..
Notice, that the 'net use' command returns 0 return value.
OS:
Problem occurs on Windows 7. It works fine on Windows XP.
This is how I connect to the remote computer in order to scan the registry:
Java Code:private void connect() { String[] cmd = new String[3]; cmd[0] = "cmd.exe"; cmd[1] = "/C"; cmd[2] = "net use \\\\" + getComputerName() + "\\ipc$ /user:" + getDomain() + "\\" + getUserName() + " " + getPassword(); Runtime rt = Runtime.getRuntime(); try { Process proc = rt.exec(cmd); int exitValue = proc.waitFor(); logger.info("'net use' exit value = " + exitValue); //TODO This line should be tested. If removed, I susspect, it fails to connect to remote registry. Thread.sleep(4000); } catch (Exception ex) { logger.severe("Exception occured while tried to connect to computer"); } }
This is how I scan for the software:
Questions:Java Code:private List<String> scanForSoftware() { logger.info(getComputerName() + "( " + getComputerDescription() + " ): scanning started .."); connect(); List installedSoftware = new ArrayList(); try { RegistryKey remoteKey = null; RegStringValue value = null; RegistryKey toplevelKey = Registry.getTopLevelKey("HKEY_LOCAL_MACHINE"); remoteKey = toplevelKey.connectRegistry("\\\\" + getComputerName() + "\\"); [COLOR="Red"][B]RegistryKey key = remoteKey.openSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", RegistryKey.ACCESS_READ);[/B][/COLOR] Enumeration enumer = key.keyElements(); //build a list of all installed software while (enumer.hasMoreElements()) { try { //monitor progress //setProgress(Math.round(((float) cycle / (float) softwareCount) * 100)); //test = Math.round(((float) cycle / (float) softwareCount) * 100); String regPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + (String) enumer.nextElement(); key = remoteKey.openSubKey(regPath, RegistryKey.ACCESS_READ); value = (RegStringValue) key.getValue("DisplayName"); installedSoftware.add(value.getData()); } catch (NoSuchKeyException ex) { //System.out.println(" No such key. Aborting."); } catch (NoSuchValueException ex) { //System.out.println(" Key not found in registry. Ignoring."); } catch (RegistryException ex) { //System.out.println(" Registry exception occured. Ignoring."); } catch (IllegalArgumentException ex) { //AppHelper.logErrorMessage(ex); } } } catch (NoSuchKeyException ex) { logger.info("Can not get key in the registry for " + this.getComputerName()); ex.printStackTrace(); } catch (RegistryException ex) { logger.info(this.getComputerName() + ": " + ex.toString()); ex.printStackTrace(); } disconnect(); logger.info(getComputerName() + "( " + getComputerDescription() + " ): " + installedSoftware.size() + " software entries found."); logger.info(getComputerName() + "( " + getComputerDescription() + " ): scanning completed .."); return installedSoftware; }
1.
Do I authenticate correctly to the remote computer with the 'net use'? Or is there other recommended way to authenticate in order to reach remote computer registry?
2.
I have disabled the UAC on Windows 7 completely (see attachment). Any idea, what else am I doing wrong?
I fight with this problem for weeks ;-/
Many thanks for your help in advance.
Juraj
- 02-10-2011, 12:41 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Sounds like a question for windows, seeing as how it semms to simply have to do with accessing a remote registry key. My guess would be that they either disabled that completely, or at least made it much harder. Security, you know, its a beach.
- 02-10-2011, 01:45 PM #3
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
...
One important thing I forgot to mention.
I get the 'access denied' error only when scanning computers from different domain. Although, there's a trust relationship set between domains, I explicitly authenticate like this (again, this works with XP):
net use \\computername\ipc$ password /user:DOMAIN\username
It is likely possible, that the error is in the authentication ..
Honestly, I don't like this 'net use' authentication method. I would be more happy to use some native Java methods with decent interface/return values ..
- 02-10-2011, 02:28 PM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Again. All I can say is that it seems to be a Windows question.
- 09-17-2011, 07:06 AM #5
Member
- Join Date
- Sep 2011
- Location
- BHOPAL (M.P.)
- Posts
- 1
- Rep Power
- 0
Re: Jni registry 'access denied' error.
Hi dear Thanks for the coding you have posted .Please help I m persuing MCA VI sem from IGNOU and i have to submit project that seems like yours I want to retrive program list installed on other pc what your coding which you have posted is not clear to me bcs im new for java but i have to that project so please help me revert soon.
I want complet coding and detailed explanation where to put files of registry jni package,
Similar Threads
-
Getting access denied error while importing file using input type="file" with IE7
By sarang1 in forum Advanced JavaReplies: 6Last Post: 02-10-2011, 09:55 AM -
Access is denied
By tholland in forum New To JavaReplies: 2Last Post: 12-20-2010, 08:57 PM -
access denied
By Dennis in forum Advanced JavaReplies: 8Last Post: 06-05-2010, 08:46 AM -
Access registry
By kkk in forum Advanced JavaReplies: 8Last Post: 09-01-2009, 12:16 PM -
[SOLVED] Access Denied error using FileInputStream
By xcallmejudasx in forum New To JavaReplies: 8Last Post: 05-21-2009, 04:13 AM


LinkBack URL
About LinkBacks

Bookmarks