【发布时间】:2020-04-08 13:45:28
【问题描述】:
我想如果 cmd 只完成标签中显示的第 10 行,但我不知道它是否可能或否如果是怎么办?也许有数组?这个程序应该在用户密码过期时得到。
private void AccountBtn_Click(object sender, EventArgs e)
{
Process pw = new Process();
pw.StartInfo.UseShellExecute = false;
pw.StartInfo.RedirectStandardOutput = true;
pw.StartInfo.FileName = "cmd.exe";
pw.StartInfo.Arguments = "/c net user " + System.Environment.UserName + " /domain";
pw.Start();
label1.Text = pw.StandardOutput.ReadToEnd();
pw.WaitForExit();
}
【问题讨论】:
标签: c# arrays cmd process line