Launching CLI application programmatically doesn't work depending on arguments

I am trying to run plink.exe

(PuTTY Link, PuTTY command line utility / version) from a C # application to establish a reverse SSH tunnel , but it no longer works as soon as I pass the correct parameters .

What does it mean? The following works as expected: it opens a command prompt window, shows that I forgot to pass the password to output the argument, -pw

and displays a prompt. I know it got the arguments as it specifically asks for one that I didn't provide.

Uri uri = omitted;
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = "cmd";
info.Arguments = "/k \"C:\\Program Files (x86)\\PuTTY\\plink.exe\" -R 3389:" + uri.Host + ":" + uri.Port + " -N -l username -pw"; // TODO pwd
Process p = Process.Start(info);

      

I tried the same with calling plink.exe

directly instead cmd.exe /k

, but the window closes immediately, which is unfortunate for finding errors.

BUT when I pass the password in the arguments, it plink.exe

displays the program help (showing the available options) and exits:

Uri uri = omitted;
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = "cmd";
info.Arguments = "/k \"C:\\Program Files (x86)\\PuTTY\\plink.exe\" -R 3389:" + uri.Host + ":" + uri.Port + " -N -l username -pw secretpassword";
Process p = Process.Start(info);

      

There is no indication of missing parameters. Both options cmd /k

and plink.exe

do not work (the latter closes immediately, so no information about other behavior).

When I launch the application from the Windows 7 launcher with identical options, it opens a window cmd.exe

and establishes a connection on demand.

What happened? Is there a way to plink.exe

mark that it doesn't work in a real shell? If so, how can I get around it like the Start Menu does?

I hope this question is right on SO as it, albeit one application specific, revolves around running successfully programmatically.

+2


a source to share


1 answer


Yes, this web page suggests Putty is getting annoyed about non-interactive logins. If the suggested solution does not help, I recommend that you ask questions about it on the Putty support forum or Superuser.com. Otherwise it had nothing to do with the Process class or C #.



0


a source







All Articles