与完全不使用cmd相比,使用cmd.exe/c的优点 [英] Advantages of using cmd.exe /c over not using cmd at all

查看:53
本文介绍了与完全不使用cmd相比,使用cmd.exe/c的优点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我正在C#中运行一个进程.与直接运行进程相比,使用cmd/c有什么好处吗?

If I'm running a process in C#. Is there any benefit to using cmd /c over just running the process directly?

例如:

ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
info.Arguments = "/c application.exe";
Process.Start(info);

相对于

ProcessStartInfo info = new ProcessStartInfo("application.exe");
Process.Start(info);

推荐答案

如果使用 cmd/c ,则可以通过用&&.例如: cmd/c"application1.exe&& application2.exe" .否则,如果只有一个流程要执行,那么直接直接执行该流程就没有区别.

If you use cmd /c, you can execute multiple commands at once by separating the commands with &&. For example: cmd /c "application1.exe&&application2.exe". Otherwise if there is only one process to execute, there is no difference to simply executing the process directly.

例如,如果进程不存在,显然 cmd/c 也可以返回错误.

Apparently cmd /c can also return an error if the process does not exist, for example.

这篇关于与完全不使用cmd相比,使用cmd.exe/c的优点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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