我使用 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=" + 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 窗口打开并运行?
白衣染霜花
MYYA
相关分类