C#-在C#winForm应用程序中打开多个cmd窗口
我使用C#为python应用程序制作GUI。我应该在cmd窗口中运行python应用程序,因为它有要向用户显示的输出 事实上,我用这个片段成功地做到了这一点:C#-在C#winForm应用程序中打开多个cmd窗口,c#,python,cmd,C#,Python,Cmd,我使用C#为python应用程序制作GUI。我应该在cmd窗口中运行python应用程序,因为它有要向用户显示的输出 事实上,我用这个片段成功地做到了这一点: Process runProg = new Process(); runProg.StartInfo.FileName = @"C:\Windows\System32\cmd.exe"; runProg.StartInfo.Arguments = @"/c py " +botFilePath +" --config_path=" + co
Process runProg = new Process();
runProg.StartInfo.FileName = @"C:\Windows\System32\cmd.exe";
runProg.StartInfo.Arguments = @"/c py " +botFilePath +" --config_path=" + configFilePath + " --config_index=username_" + index.ToString();
runProg.StartInfo.CreateNoWindow = true;
runProg.Start();
pIds[index] = System.Convert.ToInt32(runProg.Id.ToString());
但是,如果我用这段代码打开3个进程,它会工作得很好,但过了一段时间,它会关闭其中的2个进程,并继续在其中一个进程上运行。因此,它将关闭2 cmd,只保留我打开的最后一个
如何保持3个cmd窗口打开并运行?使用选项/k而不是/c启动
cmd
/K执行由字符串指定的命令,但保持不变
你有:
runProg.StartInfo.Arguments=@/c py“+botFilePath+”--config_path=“+configFilePath+”--config_index=username_”+index.ToString()代码>
/C执行命令,然后终止
/K执行命令,但保持不变
请尝试改用/K:
runProg.StartInfo.Arguments=@/K py“+botFilePath+”--config_path=“+configFilePath+”--config_index=username_”+index.ToString()代码>