Executing RegEdit from Java app

Discussion in 'Java' started by paul brown, Jan 27, 2004.

  1. paul brown

    paul brown Guest

    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
     
    paul brown, Jan 27, 2004
    #1
    1. Advertising

  2. paul brown

    paul brown Guest

    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" <> wrote in message
    news:4015fea3$...
    > 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
    >
    >
     
    paul brown, Jan 27, 2004
    #2
    1. Advertising

  3. hi ,


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

    greetings
    "paul brown" <> schreef in bericht
    news:...
    > 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" <> wrote in message
    > news:4015fea3$...
    > > 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
    > >
    > >

    >
    >
     
    Sven Goetgeluck, Jan 27, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. abidali mohammad via .NET 247

    unable find assebly folder in regedit for global assembly cache

    abidali mohammad via .NET 247, Apr 10, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    829
    Maqsood Ahmed
    Apr 14, 2005
  2. Buddy Ackerman
    Replies:
    1
    Views:
    387
    Bruce Barker
    May 11, 2005
  3. Yoshitha

    probelm in executing exe from web app

    Yoshitha, Aug 10, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    2,624
    Yoshitha
    Aug 10, 2005
  4. Yoshitha
    Replies:
    0
    Views:
    355
    Yoshitha
    Aug 19, 2005
  5. Replies:
    3
    Views:
    556
    Daniel Pitts
    Jan 3, 2007
Loading...

Share This Page