views:

43

answers:

2

Hi guys,

I need to install a .reg file (INTRANET) by using Java. How do i get my goal ?

Cheers,

+2  A: 

You could use System.exec to launch regedit yourfile.reg

Here is how to do it :

String[] cmd = {"regedit", "yourfile.reg"};
Process p = Runtime.exec(cmd);
p.waitFor();

Last line is optional, it only allows you to wait until the operation is over.

Valentin Rocher
@Valentin Rocher Valeu, mano . Muito Obrigado!
Ferinha
+2  A: 

If you're already on Java 1.6, just grab java.awt.Desktop:

Desktop.getDesktop().open(new File("c:/yourfile.reg"));

It will launch the file using the default application associated with it, as if you're doubleclicking the particular file in Windows explorer.

BalusC