使用Java显示CMD窗口 [英] Show the CMD window with Java

查看:582
本文介绍了使用Java显示CMD窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此代码启动.cmd文件:

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();
        }

它工作正常,但我想实际看到cmd.exe窗口运行。如何让它显示?

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!

推荐答案

不要运行您的路径,请尝试运行 cmd.exe ,但使用 start 命令中的构建启动新的命令窗口。您可以通过在命令提示符下输入以下命令行参数来查看完整的命令行参数集:

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

这篇关于使用Java显示CMD窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆