Cannot read configuration data from HKEY_LOCAL_MACHINE in Vista

We have a Java Web Start application and we are trying to save application configuration data using HKEY_LOCAL_MACHINE instead of HKEY_CURRENT_USER . We can force someone with administrator rights to run the application for the first time and set the configuration so that it saves the values ​​in the registry. However, subsequent Vista users without administrator rights cannot even read the values ​​from the registry into HKEY_LOCAL_MACHINE .

Perhaps our approach is wrong, and there is a better way to store application configuration data. Can anyone help?

+2
source share
3 answers

Your program is likely affected by registry virtualization .

If a 32-bit program tries to write to the registry in the HKLM\SOFTWARE section, and permissions do not allow the write to succeed, then virtualization begins. The program is informed that the recording was successful, and the data is actually recorded in HKCU\Software\Classes\VirtualStore\MACHINE\SOFTWARE . Then, when the 32-bit program tries to read from the registry, the values ​​from the VirtualStore folder VirtualStore returned to the program. Thus, the program is deceived into thinking that it was successfully written in a place where it does not have permissions, and 32-bit programs continue to work under Vista / Windows 7 without changes.

In addition, due to UAC , the admin user will be processed as if he were a non-administrator user, unless this program is specifically launched to run with administrator rights. Installer programs must be run as administrator so that they can write to the HKLM area.

+2
source

Maybe I'm wrong, but non-admin users do not have access to the HKLM period. Reading or writing.

If possible, save the settings in HKCU. If the application contains default settings, and if no HKCU values ​​are found, then the default values ​​are used and stored in the registry. Then the user should be able to change these values.

+1
source

Usually you use java.util.Preferences to store specific application data on the client machine. On Windows machines, this is behind the scenes written to the Windows registry. Here's a Sun tutorial / guide and a more technical article on the subject.

If you want more access to the Windows registry, you can find the jRegistryKey API , but this Course only works when the webstart application is running on Windows computers, and not on Linux / Mac / etc. The java.util.Preferences API is more abstract in this.

+1
source

Source: https://habr.com/ru/post/1382323/


All Articles