Java - Edit Windows 7 Registry

Asked

Viewed 56 times

0

I am having trouble changing this windows registry key with name "start" from "1" to "4".

Using a Bible.

            // Leitura de Chave
        String opcao;
        String productName = Advapi32Util.registryGetStringValue(
        WinReg.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\services\\cdrom", "Autorun");
        opcao = (productName);

        if (opcao.equals("1")) {
            Advapi32Util.registrySetStringValue(WinReg.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\services\\cdrom", "Autorun", "4");
            JOptionPane.showMessageDialog(null, "Opção modo: " + opcao + ". USBs Desativados! ", "Aviso!", JOptionPane.WARNING_MESSAGE);
        } else if (opcao.equals("4")) {
            Advapi32Util.registrySetStringValue(WinReg.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\services\\cdrom", "Autorun", "1");
            JOptionPane.showMessageDialog(null, "Opção modo: " + opcao + ". USBs Ativados! ", "Aviso!", JOptionPane.WARNING_MESSAGE);
        }
  • Difficulty is a very broad word in this context, explain to us more what your doubt and what you want to do.

  • Have you tried running the program with administrator permissions? Only administrators can make changes within HKEY_LOCAL_MACHINE

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.