У меня работает код на виртуальной машине, и я хочу получить реестр на этой машине. Но ни одна из этих работ:
//First opinion
Preferences p = Preferences.userRoot();
System.out.println("xx " + p.nodeExists("HKEY_LOCAL_MACHINE\\SOFTWARE\\Autotask Corporation\\Workplace\\Capabilities\\ApplicationName"));
//Second opinion
Preferences r = Preferences.systemRoot();
System.out.println("yy " + r.nodeExists("HKEY_LOCAL_MACHINE\\SOFTWARE\\Autotask Corporation\\Workplace\\Capabilities\\ApplicationName"));
//Third opinion
String value = WinRegistry.getString (
WinRegistry.HKEY_LOCAL_MACHINE, //HKEY
"SOFTWARE\\Autotask Corporation\\Workplace\\Capabilities", //Key
"ApplicationName"); //ValueName
System.out.println("Windows Distribution = " + value);
//Fourth opinion
WindowsRegistry reg = WindowsRegistry.getInstance();
String tree = "SOFTWARE\\Autotask Corporation\\Workplace\\Capabilities";
try {
String automationPortString = reg.readString(HKey.HKLM, tree, "ApplicationName");
}catch (RegistryException e){
logger.info(e);
}
Выход:
xx false
yy false
Windows Distribution = null
com.github.sarxos.winreg.RegistryException: Cannot read ApplicationName value from key SOFTWARE\Autotask Corporation\Workplace\Capabilities
Реестр: