I actually found out when using userRoot(), that the program indeed makes the key. It just throws a warning because java tries to make it in systemRoot() aswell, just incase you ever need it in systemroot. When you are using userRoot() you never will.
Trying to use Preferences in java but need admin rights (need to work on windows and MAC)
-
05-10-2022 - |
Question
I am trying to save some settings for my program.
I am for instance asking the user to pick a folder when the program is run for the first time.
this is all working and wonderfull, but it does not get saved.
prefs = Preferences.userRoot().node(this.getClass().getName());
Returns with WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
error code 5 (access denied)
How do i ask for admin rights? both on windows and mac, thank you for your time!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow