1

我有一段要修复的代码:

System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
//p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false; // This line will not create any new window for command prompt.
p.StartInfo.FileName = @"C:\Program Files (x86)\Citrix\System32\dscheck.exe";
p.StartInfo.Arguments = "/full groups /clean";
p.StartInfo.Arguments = argTextBox.Text;
p.Start();
System.Threading.Thread.Sleep(50);
System.Windows.Forms.SendKeys.Send("y");
System.Threading.Thread.Sleep(50);
string s = p.StandardOutput.ReadToEnd();
MessageBox.Show(s); //Shows a Popup of the output from Dscheck
//String s = p.StandardOutput.ReadToEnd();

这是我的问题:

p.StartInfo.Arguments = "/full groups /clean";
p.StartInfo.Arguments = argTextBox.Text;

我正在尝试通过tscheck.exe /full /groups /clean {UID}- UID已输入到 中argTextBox,但它不起作用。上面写着:p.StartInfo.Arguments = "/full groups /clean"; 并接受 argTextBox 并且不放置任何东西。

任何想法如何将文本框输入添加到现有参数中?

4

3 回答 3

1
p.StartInfo.Arguments = "/full groups /clean " + argTextBox.Text;

不要从文本框中分配文本,而是将其附加到现有参数。

于 2013-04-15T14:53:31.240 回答
0

只需在当前参数参数的末尾附加(当然有空格分隔符)

    p.StartInfo.Arguments = "/full groups /clean " + argTextBox.Text;
    p.Start();
于 2013-04-15T14:53:15.307 回答
0

在您要替换之前分配的值的第二个作业中,替换这些行:

p.StartInfo.Arguments = "/full groups /clean";
p.StartInfo.Arguments = argTextBox.Text;

和:

p.StartInfo.Arguments = String.Format("/full groups /clean {0}", argTextBox.Text);
于 2013-04-15T14:54:14.857 回答