tags:

views:

704

answers:

1

I'm using this code to launch a .cmd file:

try {
            String line;
            Process p = Runtime.getRuntime().exec(myPath + "\\punchRender.cmd");
            BufferedReader input =
                    new BufferedReader(new InputStreamReader(p.getInputStream()));
            while ((line = input.readLine()) != null) {
                System.out.println(line);
            }
            input.close();
        } catch (Exception err) {
            err.printStackTrace();
        }

It works fine, but I want to actually see the cmd.exe window running. How can I make it show? Any help would be greatly appreciated!

+5  A: 

Instead of running your path, try actually running cmd.exe but using the build in start command to launch a new command window. You can see the full set of command line arguments by entering the following at a command prompt:

cmd/?
start/?

in your case, you probably want to execute something like the command:

cmd /c start c:\path\to\punchRender.cmd
Eddie
Thanks, but this is giving me the same result. The CMD window stays hidden (but executes properly). Any special tricks to make it show?
Alan
P.S. wow this is already showing up #1 on google for Java show cmd :)
Alan
Looking into it...
Eddie
OK, doing this from CMD.exe launches a new CMD window, so this should do it for you.
Eddie
Perfect! The start thing is just what I needed. Thanks!
Alan