Get Process ID of Program Started with C# Process.Start
- by ThaKidd
Thanks in advance of all of your help!
I am currently developing a program in C# 2010 that launches PLink (Putty) to create a SSH Tunnel. I am trying to make the program able to keep track of each tunnel that is open so a user may terminate those instances that are no longer needed. I am currently using System.Diagnostics.Process.Start to run PLink (currently Putty being used). I need to determine the PID of each plink program when it is launched so a user can terminate it at will.
Question is how to do that and am I using the right .Net name space or is there something better?
Code snippet:
private void btnSSHTest_Click(object sender, EventArgs e)
{
String puttyConString;
puttyConString = "-ssh -P " + cboSSHVersion.SelectedText + " -" + txtSSHPort.Text + " -pw " + txtSSHPassword.Text + " " + txtSSHUsername.Text + "@" + txtSSHHostname.Text;
Process.Start("C:\\Program Files (x86)\\Putty\\putty.exe", puttyConString);
}