The CMD prompt opened from Visual Studio will not start exe on my computer. Why not?

I have the code below to run the cmd command line and from this cmd prompt run putty.exe with and the IP address at the end.

private void btnRouter_Click(Object sender, EventArgs e)
{
    MessageBox.Show((string)((Button)sender).Tag);
    System.Diagnostics.Process cmd = new System.Diagnostics.Process();
    cmd.StartInfo.FileName = @"C:\windows\system32\cmd.exe";
    cmd.StartInfo.UseShellExecute = true;
    cmd.Start();
    cmd.StandardInput.WriteLine("Putty.exe " + ((string)((Button)sender).Tag));
    cmd.WaitForExit();
}

The problem is that I get the error "StandardIn not redirected" all the time. from Visual Studio, and when I try to enter putty.exe in the command window that appears, I get "putty.exe" is not recognized as an internal or external command, "operating program or batch file". This is REALLY strange, because if I go to the execution line, type cmd, and then putty.exe opens immediately since I added the absolute folder path to the epee application to my path to the system environment.

, CMD, Visual Studio, ?

- , , putty.exe .

private void btnRouter_Click(Object sender, EventArgs e)
{
    MessageBox.Show((string)((Button)sender).Tag);
    System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
    System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
    startInfo.FileName = "Putty.exe ";
    startInfo.Arguments = ((string)((Button)sender).Tag);
    myProcess.StartInfo = startInfo;
    myProcess.Start();
}
+4
2

, "StandardIn ". , stdin :

cmd.StandardInput.WriteLine("Putty.exe " + ((string)((Button)sender).Tag));

:

, CMD, Visual Studio, ?

, .

, cmd, , Visual Studio, , Visual Studio , .

, , Visual Studio cmd.

cmd , , , Visual Studio .

+3

All Articles