I have created a .bat file that displays all the users logged in Windows Terminal Services. I can execute the .bat file in my c# code behind and display the results in plain text in a label or text box. What i would like to do is data bind the user name and the session ID in a data grid.
protected void Button1_Click(object sender, EventArgs e)
{
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(@"C:\listfiles.bat");
psi.RedirectStandardOutput = true;
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
System.Diagnostics.Process listFiles;
listFiles = System.Diagnostics.Process.Start(psi);
System.IO.StreamReader myOutput = listFiles.StandardOutput;
listFiles.WaitForExit(2000);
if (listFiles.HasExited)
{
string output = myOutput.ReadToEnd();
// this.TextBox1.Text = output;
}
}