1

I need to execute the following command in Visual Studio:

dsquery group -name "groupname" |dsget group -members

This works fine in command prompt, but doesn't give any output in Visual Studio. I am using following code snippet.

private void button1_Click(object sender, EventArgs e)
{
string groupname =" " + "group" + " " + "-name" + " " + search_box.Text+"dsget"+" "+"group"+" "+"-members";
    ProcessStartInfo psi = new ProcessStartInfo("dsquery", groupname);
    psi.UseShellExecute = false;
    psi.RedirectStandardOutput = true;
    psi.CreateNoWindow = true;
    var proc = Process.Start(psi);
    string s = proc.StandardOutput.ReadToEnd(); 
    textBox1.Text = s;
}

Please let me know what is wrong with this code?

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
  • You cannot see error messages if you don't also redirect StandardError. *Some* flaky executables only work if you also redirect StandardInput, XCopy.exe is an example. – Hans Passant May 16 '16 at 17:41
  • I am not concerned about Error.I am only worried about running the piped command.This code works well without piped command. – Aishwary Vardhan May 17 '16 at 12:39

0 Answers0