I'm trying to run a powershell script in my C# form application. The powershell script pings a certain machine every .5 seconds and displays an output until exited.
I can run the script and open it up in powershell, but I want the output to display the LIVE ping results in a C# form label (or ritchtextBox if that isn't possible)
Here's the code I currently have that runs the program externally.
private void Btn_Ping_Click(object sender, EventArgs e)
{
ProcessStartInfo proc = new ProcessStartInfo();
proc.FileName =
@"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe";
proc.Arguments =
@"//ctac.1800contacts.com/service/hd_image/tools/LatencyTest.bat " +
Txt_Main.Text.Trim();
Process.Start(proc);
richTextBox1.AppendText("Started pinging " + Txt_Main.Text +
"\r\n");
Txt_History.ScrollToCaret();
}
I expect the code to display an output within my windows form application, but not actually pull up powershell. Is this possible?