C# 打开cmd.exe,然后运行我当前的控制台应用程序
以下是我想要实现的目标:C# 打开cmd.exe,然后运行我当前的控制台应用程序,c#,C#,以下是我想要实现的目标: 假设我正在准备abc.exe(控制台应用程序) 我想调用cmd.exe,然后通过cmd启动abc.exe。我不会将cmd.exe保存在我的项目文件夹中。我将从用户机器的system32文件夹中使用它 有可能吗?如评论中所述,您可以使用Process.Start(pathToExe)启动新流程 您可以在新的cmd中启动程序,使用cmd/C start“Title”C:\path\to\app.exe“: 你可能需要一些条件来保证你自己不被炸所以,你需要abc.exe启动c
有可能吗?如评论中所述,您可以使用
Process.Start(pathToExe)
启动新流程
您可以在新的cmd中启动程序,使用cmd/C start“Title”C:\path\to\app.exe“
:
你可能需要一些条件来保证你自己不被炸所以,你需要
abc.exe
启动cmd.exe
,然后让cmd.exe
启动另一个abc.exe
?请检查答案以了解详细信息你可以使用进程。启动(“cmd.exe”)
谢谢!是的,我会处理的。
string cmdPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "cmd.exe");
string exePath = System.Reflection.Assembly.GetEntryAssembly().Location;
ProcessStartInfo newCmd = new ProcessStartInfo(cmdPath);
newCmd.Arguments = String.Format(@"/C start ""{0}"" ""{1}""", "WindowTitle", exePath);
Process.Start(newCmd);