Executing RegEdit from Java app

P

paul brown

Hi

i'm trying to update my registry from Java (ugly, i know!)

i'm doing this:

public class Registry{
public static void main(String[] args){
try{
Process proc =
Runtime.getRuntime().exec(
new String[]{"cmd",
"/C",
"regedit"+
"/S"+
Registry.REGFILE});
proc.waitFor();
proc.destroy();
}
catch(Throwable th){
th.printStackTrace();
}
}

public static String REGFILE ="regfile.reg";
}


The problem is that when i run the program the registry doesnt get updated.

regedit.exe is on the path of the program.

The registry file is in the working directory of the program.

If i run the 'regedit' command by hand , from a DOS box, using the same
registry file, it works.

Any ideas?

Thanks in advance,
Paul
 
P

paul brown

found the solution:


public void register(){
try{
Process proc =
Runtime.getRuntime().exec(
"regedit /S "+Registry.REGFILE);
proc.waitFor();
proc.destroy();
}
catch(Throwable th){
th.printStackTrace();
}
}


thanks
Paul
 
S

Sven Goetgeluck

hi ,


was wondering how to change keys or add some new keys to the registry

greetings
paul brown said:
found the solution:


public void register(){
try{
Process proc =
Runtime.getRuntime().exec(
"regedit /S "+Registry.REGFILE);
proc.waitFor();
proc.destroy();
}
catch(Throwable th){
th.printStackTrace();
}
}


thanks
Paul




paul brown said:
Hi

i'm trying to update my registry from Java (ugly, i know!)

i'm doing this:

public class Registry{
public static void main(String[] args){
try{
Process proc =
Runtime.getRuntime().exec(
new String[]{"cmd",
"/C",
"regedit"+
"/S"+
Registry.REGFILE});
proc.waitFor();
proc.destroy();
}
catch(Throwable th){
th.printStackTrace();
}
}

public static String REGFILE ="regfile.reg";
}


The problem is that when i run the program the registry doesnt get updated.

regedit.exe is on the path of the program.

The registry file is in the working directory of the program.

If i run the 'regedit' command by hand , from a DOS box, using the same
registry file, it works.

Any ideas?

Thanks in advance,
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top