任何方法来保持一个外部命令窗口中打开过程中的Process.Start(..)? [英] Any way to keep an external command window open during a Process.Start(..)?

查看:173
本文介绍了任何方法来保持一个外部命令窗口中打开过程中的Process.Start(..)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经得到它运行一个批处理文件以下code。 bat文件并运行一些.exe文件..,做一些东西。的东西需要不要蜘蛛5-10秒。

i've got the following code which runs a bat file. the bat file then runs some .exe .. which does some stuff. The stuff takes aroun 5-10 seconds.

ProcessStartInfo start = new ProcessStartInfo
{
    Arguments = "\"" + newTargetFile + "\"" +
                " " +
                "\"" + originalFile.FullName + "\"",
    FileName = filename,
    WindowStyle = ProcessWindowStyle.Normal,
    CreateNoWindow = false,
    UseShellExecute = false
};

// Run the external process & wait for it to finish
using (Process proc = Process.Start(start))
{
    proc.WaitForExit();
}

我想要做的就是离开命令窗口打开,这个过程结束后还是一样。有没有办法做到这一点?

What i'm trying to do is leave the command window open, even after the process terminates. Is there any way to do this?

否则,我可以得到该窗口的所有输出去我的调试器来代替,所以我不需要担心这个窗口剩余?

Otherwise, can i get all the output of that window going to my debugger instead, so i don't need to worry about this window remaining?

欢呼声。

推荐答案

如果您运行CMD间preTER用/ K参数,并通过在批处理文件名作为一个参数,你应该得到你再后。该/ K参数告诉Windows离开CMD间preTER打开时,它不管你告诉它做作为一个参数进行。

If you run the cmd interpreter with a /k argument and pass in the batch file name as the next argument, you should get what you're after. The /k argument tells Windows to leave the cmd interpreter open when it's done with whatever you tell it to do as the next argument.

您可以当然也使用RedirectStandardOutput属性,但我认为这将是最终要复杂得多。

You could certainly also use the RedirectStandardOutput property, but I think that would be more complicated in the end.

这篇关于任何方法来保持一个外部命令窗口中打开过程中的Process.Start(..)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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