Get Process ID of Program Started with C# Process.Start

Posted by ThaKidd on Stack Overflow See other posts from Stack Overflow or by ThaKidd
Published on 2010-06-14T16:23:06Z Indexed on 2010/06/14 16:32 UTC
Read the original article Hit count: 279

Filed under:
|
|

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);
}

© Stack Overflow or respective owner

Related posts about visual-studio-2010

Related posts about c#4.0