I am trying to create new Windows Explorer Context menu items dynamically responding to user actions in my java application. This involves creating new keys under HKEY_LOCAL_MACHINE in the Windows Registry (so far as I know this is the only method, if that is not true someone please enlighten me)
I have tried the following command:
ProcessBuilder pb=new ProcessBuilder("cmd.exe", "/c", "reg add HKLM\\SOFTWARE\\Classes\\*\\shell\\My Application Name");
pb.redirectErrorStream(true);
Process process=pb.start();
however I recieve the error "Access Denied" because you need admin privileges. I have tried some other code by actually accessing the private methods in the java.util.prefs.Preferences but this also did not work.
It would suffice to have the user be prompted to put in their administrator account password to create the registry key. If there are any other possible methods that do not involve the user manually creating the keys that would work as well. Thanks in advance!!