使用Process.Start(),当/ K参数不工作时,如何保持cmd提示打开? [英] With Process.Start(), How can I keep cmd prompt open when the /K argument doesn't work?

查看:132
本文介绍了使用Process.Start(),当/ K参数不工作时,如何保持cmd提示打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

以任何方式在Process.Start(..)期间保持外部命令窗口打开?

我已经看过这篇文章,但是由于某些原因,这些解决方案不适合我。使用Process.Start(),当/ K参数不工作时,如何保持cmd提示打开?还没有WaitForExit方法可用。

I've seen this post before but those solutions don't work for me for some reason. With Process.Start(), How can I keep cmd prompt open when the /K argument doesn't work? There's also no "WaitForExit" method available.

ProcessStartInfo processInfo = new ProcessStartInfo("cmd.exe", "/K " + "C:\\Windows\\System32\\" + "takeown.exe");
processInfo.Verb = "runas";
processInfo.Arguments = "/F \"C:\\Program Files(x86)\\Borland\" /R /D Y";
Process.Start(processInfo);

我想看到的是如果处理成功。

What I want to see is if the process processed successfully.

感谢

推荐答案

您可以等待流程完成后再继续:

You can wait for the process to finish before continuing:

var process = Process.Start(processInfo);
process.WaitForExit();
if (process.ExitCode != 0) {
    // Handle failure...
}

这篇关于使用Process.Start(),当/ K参数不工作时,如何保持cmd提示打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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