1

To read registry i have running code. but it wont work on restricted environment. following is the code.

private ArrayList<String> getVirtualPrinterlist(){
ArrayList<String> VirtualPrinterlist = new ArrayList<String>();
try{
    String [] keys = Advapi32Util.registryGetKeys (HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers" );
    for (String key : keys) {
        System.out.print(key+" #  ");
        String ipString=Advapi32Util.registryGetStringValue (HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers\\"+key, "Port");
        System.out.println(ipString) );

        VirtualPrinterlist.add(key);

    }
}catch (Exception e) {  
    e.printStackTrace();
}
return VirtualPrinterlist;
  }
Arjun Patil
  • 111
  • 9
  • 1
    I don't think you can do anything about it when the environment is restricted. Have you tried if you can see the registry entries without admin rights? – Tobias Brösamle May 20 '16 at 07:14
  • Most likely your library is buggy - heres a JRE solution without libraries : http://stackoverflow.com/a/6163701/351861 – specializt May 20 '16 at 08:19

1 Answers1

1

You can not read the Registry from remote systems if the windows firewall is on. This even would not work with windows board tools. If you are in a Domain-Environment, you can define a local or global group policy to set the firewall inactive or off.

Also, windows users (accounts that are only in the group Users) do not have the right to write to HKLM, only to their environmental trees like HKCU.

If you want to change registry settings, I recommend you to use the command line prompts by calling over the Runtime class. You can also add separate adminsitrator parameters here.

Supahupe
  • 515
  • 2
  • 11