gpt4 book ai didi

c# - 如何从进程中获取输出?

转载 作者:太空宇宙 更新时间:2023-11-03 15:21:36 24 4
gpt4 key购买 nike

所以这是我当前的代码:

 private void StartButton_Click(object sender, EventArgs e)
{
Download = "placeholdercommand"

string CWD = System.IO.Directory.GetCurrentDirectory();

Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();

startInfo.Verb = "runas"; ///launch as admin
startInfo.FileName = "cmd.exe"; ///launch cmd
startInfo.Arguments = "/k cd /d " + CWD + "&" + ///navigate cmd to CWD (/k = return)
Download + "&" + ///give Download order to cmd
"exit"; ///exit cmd

process.StartInfo = startInfo;
process.Start();
}

现在我想让 cmd 窗口不可见,并在我的 c# 窗口中实时显示 cmd 工作。我该怎么做?

最佳答案

用它来隐藏

info.WindowStyle=ProcessWindowStyle.Hidden;

获取输出

while (!process.StandardOutput.EndOfStream)
{
string Line = process.StandardOutput.ReadLine();
}

关于c# - 如何从进程中获取输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37138911/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com