如何打开Putty进程没有它打开在另一个窗口

本文关键字:另一个 窗口 何打开 Putty 进程 | 更新日期: 2023-09-27 18:12:30

使用本规范

    Process process = new Process();
    // p.EnableRaisingEvents = true;
    process.EnableRaisingEvents = true;
    process.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
    process.StartInfo.RedirectStandardOutput = true;
    process.StartInfo.CreateNoWindow = true;
    process.StartInfo.LoadUserProfile = false;
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.FileName = @"C:'putty.exe"; ; // Gets or sets the application or document to start.
    process.StartInfo.Arguments = "-serial com31 -sercfg 9600,8,n,1,N";//Gets or sets the set of command-line arguments to use when starting the application      
    Thread.Sleep(1000);
    process.Start();//Starts (or reuses) the process resource that is specified by the StartInfo property of this Process component and associates it with the component.   
    process.BeginOutputReadLine();
    process.WaitForExit(); // wait forever with ping

我试图在控制台应用程序中打开putty,但是任何时候我使用它,它都会在新窗口中打开,我无法使用process.OutputDataReceived事件获得进程的输出

我使用的代码非常类似于这个打开Iperf,它工作良好

我在这里错过了什么?

如何打开Putty进程没有它打开在另一个窗口

Putty不是一个console application,因此不提供输出在它的stdoutstderr流。

并且因为 windowed application,所以它不关心您是否以CreateNoWindow标志开始。试着用这个标志启动notepad.exe,你会看到它明显地出现。

然而,Putty的创建者提供了一个程序,提供了您需要的功能。

叫做Plink.exe你可以在他们的主页上下载